mercredi 24 juin 2020

Laravel remove pending migration execution

I have two Laravel apps that use the same database. I moved migrations from app 1 to app 2. Now I want to remove the pending migrations from app 2 due to that I moved the migrations files to it and tables exists in database.

Is any way to remove them from pending execution when php artisan migrate is executed?

Regards



via Chebli Mohamed

laravel eger loading not working properly when i use limit or take in whereIn

helllo my code is

$all_5_post = wp_terms::with(['wp_posts' => function ($query) {
                                      $query->orderBy('id', 'desc')->take(5);
                                }])->whereIn('id',[3,4,6,9])->get();

getting relationship data in 3 id but 4,6,9 relationship data getting empty but when i only use WHERE elequent and doing multiple query for same 3,4,6,9 id it showing 5 relationship table data in each what i have to do now i need a solution.



via Chebli Mohamed

how to store the select value of select box for search

Dear Stackoverflow team! i want to make the search condition with form like picture attachment. i want to store the select box value after form submit to search with multiple condition. so could the the team help make solution for it. below is my model filter condition, it's laravel code

public function scopeFilterInProfile($query, Request $request)
{
    $query = Property::where('user_id',auth()->user()->id)
                    ->published()
                    ->expired();
    if ($request->input('category')) {
        $query->where('parent_id', $request->input('category'));
    }
    if ($request->input('location')) {
        $query->where('province_id', '=', $request->input('location'));
    }
    if ($request->input('search')) {
        $query->where('title', 'LIKE', '%'.$request->input('search').'%');
    }
    if ($request->input('from_price') && $request->input('to_price')) {
        $query->whereBetween('price', [$request->input('from_price'),$request->input('to_price')]);
}
    if ($request->input('sort')) {
        switch ($request->input('sort')){
            case 'posted_date_desc':
                $query->orderBy('created_at', 'DESC');
                    break;
            case 'posted_date_asc':
                $query->orderBy('created_at', 'ASC');
                    break;
            case 'renew_date_desc':
                $query->orderBy('renew_date', 'DESC');
                    break;
            case 'renew_date_asc':
                $query->orderBy('renew_date', 'ASC');
                    break;
            case 'price_desc':
                    $query->orderBy('price', 'DESC');
                    break;
            case 'price_asc':
                $query->orderBy('price', 'ASC');
                    break;
            default:
                $query->orderBy('posted_date_desc', 'DESC');
        }
    }
    return $query;
}

myform search picture



via Chebli Mohamed

I got symfony/translation errors installing laravel 5 on remote server

Uploading my laravel 5 app on ubuntu under Digital Ocean server I got error in the browser:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

Googling for decision I found that the error could need symfony/translation installation and I tried to install it locally on my kubuntu 18 and got error :

$ composer require symfony/translation                                     
Using version ^5.1 for symfony/translation
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install symfony/translation v5.1.2
    - Conclusion: don't install symfony/translation v5.1.1
    - Conclusion: don't install symfony/translation v5.1.0
    - Conclusion: don't install symfony/translation v5.1.0-RC2
    - Conclusion: don't install symfony/translation v5.1.0-RC1
    - Conclusion: don't install symfony/translation v5.1.0-BETA1
    - Conclusion: don't install symfony/translation 5.2.x-dev
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - symfony/translation 5.1.x-dev conflicts with symfony/http-kernel[v4.4.9].
    - Installation request for symfony/translation ^5.1 -> satisfiable by symfony/translation[5.1.x-dev, 5.2.x-dev, v5.1.0, v5.1.0-BETA1, v5.1.0-RC1, v5.1.0-RC2, v5.1.1, v5.1.2].
    - Installation request for symfony/http-kernel (locked at v4.4.9) -> satisfiable by symfony/http-kernel[v4.4.9].

My local composer.json :

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "arrilot/laravel-widgets": "^3.13",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mews/purifier": "^2.1",
        "phpoffice/phpspreadsheet": "^1.6",
        "proengsoft/laravel-jsvalidation": ">2.2.0",
        "s-ichikawa/laravel-sendgrid-driver": "^2.0",
        "spatie/browsershot": "^3.37",
        "spipu/html2pdf": "^5.2",
        "yajra/laravel-datatables-oracle": "~8.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

How this can be salved ? Thanks!



via Chebli Mohamed

Laravel Api and Web Authentication At Same Time

i'm building cross-platform app so i have website and mobile app. also I've Authentication part for both website and app.

and i'm using Laravel As backend. For auth i found something called "Auth Guards" and there are two default Auth guard in Laravel, one for web and other for API.

But i'm a bit confused cause i found that you can't use both Auth Guards at the same time.

So, is there any way to build authentication system based in one Database Table For Website an Mobile.

NOTE i need any solution except Firebase Auth



via Chebli Mohamed

Azure AD identity provider with laravel 5.2

Can I implement azure AD as a identity provider with my laravel version 5.2? If yes can anyone give me link or suggest something about it? you can also suggest me another identity provider which will be compatible with laravel 5.2.



via Chebli Mohamed

Search value in array in Laravel Blade

I am beginner in Laravel.

I have array in variable $selectedProductFeatures:

array:9 [▼
  0 => array:9 [▼
    "id" => 9
    "product_id" => 3
    "feature_id" => 1
    "key" => "price60"
    "description" => "60"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  1 => array:9 [▼
    "id" => 10
    "product_id" => 3
    "feature_id" => 1
    "key" => "price60_promo"
    "description" => "65"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  2 => array:9 [▼
    "id" => 11
    "product_id" => 3
    "feature_id" => 1
    "key" => "price90"
    "description" => "90"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  3 => array:9 [▼
    "id" => 12
    "product_id" => 3
    "feature_id" => 1
    "key" => "price90_promo"
    "description" => "95"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  4 => array:9 [▼
    "id" => 13
    "product_id" => 3
    "feature_id" => 1
    "key" => "countertop_length"
    "description" => "1000.00"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  5 => array:9 [▼
    "id" => 14
    "product_id" => 3
    "feature_id" => 1
    "key" => "countertop_type"
    "description" => "4"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  6 => array:9 [▼
    "id" => 15
    "product_id" => 3
    "feature_id" => 1
    "key" => "maintenance"
    "description" => "<p>konserwacja</p>"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  7 => array:9 [▼
    "id" => 16
    "product_id" => 3
    "feature_id" => 1
    "key" => "other_title"
    "description" => "tytuł inny"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
  8 => array:9 [▼
    "id" => 17
    "product_id" => 3
    "feature_id" => 1
    "key" => "other_description"
    "description" => "<p>opis inny</p>"
    "maxvalue" => "0.00"
    "minvalue" => "0.00"
    "created_at" => "2020-06-24T08:27:35.000000Z"
    "updated_at" => "2020-06-24T08:27:35.000000Z"
  ]
]

return view('admin.products.view', ['selectedProductFeatures' =>$selectedProductFeatures->toArray(), 'productTypes' => $productTypeRepository->allEnables('name', $orderBy = 'asc', $with = []), 'fileCount' => 5, 'fileFolder' => 'products', 'fileId' => $id, 'product' => $this->model->findOrFail($id), 'categories' => $categories, 'taxVat' => $vatRepository->allEnables('value', 'asc'), 'page_title' => 'Produkty', 'page_breadcrumbs' => [['page' => route('product.index'), 'title' => 'Produkty'], ['page' => '#', 'title' => 'Edytuj produkt']]]);

My blade file:

<input type="text" name="price60" value="">
<input type="text" name="price90" value="">

In price60 I need show value from array (array is dynamic).

"key" => "price60" -- this is name input "description" => "60" - this value to show.

In result I need:

For "key" => "price90" and "description" => "90" in input I need show:

<input type="text" name="price90" value="90">

How can I make it?



via Chebli Mohamed