hello every one
i have a Category model and its have only name and image field
so for making a new category its work fine
but when its come to update
i have a small issue
i make the code work like this :-
1 - if the user upload a file then it will take the file and put the path on the field 2 - if not then it will grab the previous value of the image field and put it in the field
the problem with the first step
its upload the file but its return an empty value in the image field and dosnt update it !!
this is my code
http://laravel.io/bin/eDDkn#17-18
i try to use
$request->merge([ 'image' => public_path().'/images/categories/'.$image;, ]);
but same thing
it always give me this response
{ "id": 1, "name": "Small Car2", "created_at": "2015-05-21 12:51:11", "updated_at": "2015-05-22 08:14:11", "image": {} }
as the image : {}
and btw even when the field not updated the file was upload and move successfully
Do you add $fillable variable in your category model?
barisbora said:
Do you add $fillable variable in your category model?
i think u didnt read my issue
i dont have issue with mass assignment as it work in the second condition
and also it work when i need to store a new category
no need i just find a way
$category->update([ 'name'=> $request->get('name'), 'image' => $request->get('image') ]);
will solve it
i dono why
$category->update($request->all());
have an issue >_<
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community