Last active
May 29, 2017 16:13
-
-
Save bmadigan/c89762f5aa7735c7827a78c8e427530d to your computer and use it in GitHub Desktop.
Remove Multiple Assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function destroy(Request $request, $id = null) | |
{ | |
abort_unless($this->authUser->hasPermissionTo('manage assets'), 403); | |
$requestData = $id ? | |
[$request->all() + ['id' => $id]] : | |
json_decode($request->getContent(), true); | |
$assets = Asset::findOrFail(collect($requestData)->pluck('id')->toArray()); | |
foreach ($requestData as $data) { | |
$asset = $assets->find($data['id']); | |
$asset->delete(); | |
} | |
return response()->json(['message' => 'asset removed'], 204); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment