Trying to update my Auth:user() Product with update method, but always results in Error. User has many products() / Product belongsTo user().
$this->validate($request, [
'title'=> 'max:140',
'brand'=> 'max:140',
'sku'=> 'max:140',
'description'=> 'max:140',
'price'=> 'max:140',
'availability'=> 'max:140',
]);
$product = auth()->user()->products()->findOrFail($id);
$product->update([
'title' => $request->input('title'),
'brand' => $request->input('brand'),
'sku' => $request->input('sku'),
'description' => $request->input('description'),
'price' => $request->input('price'),
'availability' => $request->input('availability'),
]);
Am I missing something within my Controller? Btw.
Auth::user()->products()->update([
'title' => $request->input('title'),
'brand' => $request->input('brand'),
'sku' => $request->input('sku'),
'description' => $request->input('description'),
'price' => $request->input('price'),
'availability' => $request->input('availability'),
]);
updated every User related product to the same values.
So the problem is within the Product specification.
Any suggestions? Thank you
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BxgXtG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire