Jocky Doe Jocky Doe - 1 year ago 85
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.

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