本文整理匯總了PHP中Food::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Food::find方法的具體用法?PHP Food::find怎麽用?PHP Food::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Food
的用法示例。
在下文中一共展示了Food::find方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteFood
public function deleteFood($id)
{
$food = Food::find($id);
if ($food->delete()) {
return Redirect::route('userHome')->with('success', 'User deleted successfuly');
} else {
return Redirect::route('userHome')->with('fail', 'Error while deleting food');
}
}
示例2: date
if ($food->user_id != $user->user_id) {
return $response->write('{"msg":"Yetkisiz erişim"}');
}
$food->name = $newFood->name;
$food->materials = $newFood->materials;
$food->description = $newFood->description;
$food->last_update_date = date("YmdHi");
if ($food->save()) {
return $response->getBody()->write(json_encode($food) . ' ');
}
return $response->getBody()->write('{"msg": "ERR"}');
})->setName('food_update');
// yemek sil
$this->delete('/{id:[0-9]+}', function ($request, $response, $args) {
$user = Token::where('token', '=', $request->getHeader('token')[0])->get()->first()->user();
$food = Food::find($args['id']);
if ($food->user_id != $user->user_id) {
return $response->write('{"msg":"Yetkisiz erişim"}');
}
$food->deleted = true;
if ($food->save()) {
return $response->write('{"msg": "OK"}');
}
return $response->write('{"msg": "ERR"}');
})->setName('food_delete');
})->add($UserToken);
$app->group('/comment', function () {
// yorum ekle
$this->post('', function ($request, $response, $args) {
$user = Token::where('token', '=', $request->getHeader('token')[0])->get()->first()->user();
$newComment = json_decode($request->getBody());
示例3: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
return Food::find($id);
}
示例4: destroy
/**
* Remove the specified resource from storage.
* DELETE /foods/{id}
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$food = Food::find($id);
$food->delete();
return Redirect::route('foods.index');
}