Jocky Doe Jocky Doe - 9 months ago 60
reST (reStructuredText) Question

Mass CRUD REST edit/update controller

I am trying to create a RESTful CRUD controller with a little but significant difference that might be in conflict with REST idea but anyway:

I am trying to mass edit items like so

where item id parameters are like

What is the proper way to establish that in Laravel 5.3?
Is there a way to use some method injections or at least to receive a collection of parameters in the controller method ?

public function edit($id) {

Appreciate your kind help, BR

Answer Source

Using Eloquent you can do whereIn, so you just need to explode the photo parameter so that all the ids are in an array:

public function edit($ids) {
    $photo_ids = explode('&', $ids);

    $images = Image::whereIn('id', $photo_ids)->get();

You can switch out statically accessing the Image model like I did in this example, you can just method inject or dependency inject the image model, let me know if you'd like assistance with dependency/method injection.