当前位置: 首页>>代码示例>>PHP>>正文


PHP Food::find方法代码示例

本文整理汇总了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');
     }
 }
开发者ID:milos01,项目名称:fridgeeapp.tk,代码行数:9,代码来源:UserController.php

示例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());
开发者ID:gokselpirnal,项目名称:WhatTheFood-web,代码行数:31,代码来源:routes.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     return Food::find($id);
 }
开发者ID:mawaha,项目名称:tracker,代码行数:10,代码来源:FoodsController.php

示例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');
 }
开发者ID:JustinMackenzie,项目名称:meal-log,代码行数:13,代码来源:FoodsController.php


注:本文中的Food::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。