public function deleteProduct($id) { if (Request::ajax()) { $arrReturn = ['status' => 'error', 'message' => 'Please refresh and try again.']; try { $product = Product::findorFail($id); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { return App::abort(404); } $name = $product->name; if ($product->delete()) { $arrReturn = ['status' => 'ok', 'message' => "<b>{$name}</b> has been deleted."]; } $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; } return App::abort(404); }