Reputation: 325
I need to delete a photo from an Album so I think I need 2 parameter on Routing but I get some error please give me solution or another way to delete a photo from an album
here's my Routes.php :
Route::get('/admin/album/{albumid}/{id}/delete-photo', array(
'as' => 'admin-photo-delete',
'uses' => 'GalleryController@deletePhoto'
));
and call a function deletePhoto on GalleryController, here's GalleryController :
public function deletePhoto($albumID,$photoID){
$photo = Album::find($albumID)->photo()->where('id','=',$photoID)->get();
if($photo){
File::delete(public_path().'/assets/images/gallery/'.$photo->images);
$photo->delete();
return Redirect::route('admin-gallery')->with('message','Photo was deleted successfully');
}
return Redirect::route('admin-gallery')->with('message','Photo delete failed');}
and here how I call route :
<a href="{{URL::route('admin-photo-delete',$id,$photo->id)}}">Delete Photo</a>
I already make sure that $id and $photo->id was not null but see what url showing there's no second parameter value so I get some error:
Upvotes: 0
Views: 21677
Reputation: 14970
In URL::route
, you should use an array as the second parameter, like this:
<a href="{{URL::route('admin-photo-delete', [$id, $photo->id] )}}">Delete Photo</a>
Upvotes: 13