neuroine neuroine - 1 year ago 243
PHP Question

Laravel-Backpack image field debug

I have a problem with saving one field, how can I debug?

in AdvertController.php has no effect. All other fields are stored properly.


class AdvertController extends Controller
public function store(Requests\StoreAdvertPostRequest $request)


public function edit($id)

$articlePicture = Advert::find($id)->photos[0]->file_name;

$path = 'uploads/photos/' . $articlePicture;

'name' => 'photo',
'label' => 'Profile Image',
'type' => 'image',
'value' => $path,
'crop' => true,
'aspect_ratio' => 0.75,

return parent::edit($id);

Finally, I would also like to pass the coordinates of the crop to store method.

Update 1:

When I add new photo it works fine, but when I get existing file, photo show up without all controls. Displays only 'Choose file' and trash button.

Answer Source

The "store" method is only called when creating an entry, not editing. Perhaps you were trying to edit? Then the dd() should be placed inside the update() method. But that's in the CrudController, not the regular one. I have no idea what your regular controller does.

Usually when the value does not get stored in the database it's because you forgot to place the column in the $fillable attribute on the model.

Also, because this is an upload field, you should create a mutator that also places the file on disk. The "image" field documentation has it.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download