mardi 28 août 2018

Get the Value of the UUID of a Model

I get this error:

Type error: Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in /Users/Kit/sampleproject/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 131

because of this:

    $user = Auth::user()->uuid;
    $store = Store::where('created_by_id', $user)->first();
    $store_id = Store::where('uuid', $store)->get('uuid');

in which I want to get the store uuid, I have the user's credentials, and I can find if that user has a store by comparing the user's uuid and the created_by_id that belongs to the store table, that explains the 2nd line, and in the 3rd line, I want to get the uuid of that particular store and save it as a new item yet I do not know what the correct syntax for that.

        $product = Product::firstorCreate([
            'store_id' => $store_id,
            //more code here
        ]);

I want to pass the value here.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire