本文整理汇总了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');
}