/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $biz = Biz::findOrFail($id); $cat = $biz->cats->lists('id')->all(); // dd($cat); $sub = $biz->subcats->lists('id')->all(); $biz->cats()->detach($cat); $biz->subcats()->detach($sub); $biz->address()->delete(); $biz->delete(); return redirect('/admin/biz')->withSuccess("The business '{$biz->name}' has been deleted."); }
public function bizphotos(Request $request, $id) { $file = $request->file('file'); $name = time() . $file->getClientOriginalName(); $file->move('biz/photos', $name); $biz = \App\Biz::findOrFail($id); $biz->photos()->create(['path' => "/biz/photos/{$name}"]); return 'Done'; }