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


PHP Categories::whereId方法代码示例

本文整理汇总了PHP中app\models\Categories::whereId方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::whereId方法的具体用法?PHP Categories::whereId怎么用?PHP Categories::whereId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Categories的用法示例。


在下文中一共展示了Categories::whereId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDelete

 public function getDelete($id)
 {
     $result = array('state' => 0, 'msg' => '');
     try {
         if (!$id) {
             throw new \Exception("Id de Categoria vacio");
         }
         $user = Categories::whereId($id)->first();
         $user->update(['id' => $id, 'flagactive' => 0]);
         $user->delete();
         $result['state'] = 1;
     } catch (\Exception $e) {
         $result['msg'] = $e->getMessage();
     }
     return response()->json($result);
 }
开发者ID:josmel,项目名称:buen,代码行数:16,代码来源:CategoryController.php

示例2: getAllAds

 public function getAllAds($category = null, $description = null, $user_id = null, $page, $type = null)
 {
     try {
         $data = PuAds::leftJoin('pu_pictures', 'pu_ads.id', '=', 'pu_pictures.pu_ad_id')->join('pu_types as t', 'pu_ads.pu_type_id', '=', 't.id')->join('users as u', 'pu_ads.user_id', '=', 'u.id')->join('pu_categories as ca', 'pu_ads.pu_category_id', '=', 'ca.id')->leftJoin('pr_providers as p', 'pu_ads.pr_provider_id', '=', 'p.id')->leftJoin('pr_comments as pc', 'pu_ads.pr_provider_id', '=', 'pc.id')->leftJoin('pr_types as prt', 'p.pr_type_id', '=', 'prt.id')->select('pu_ads.*', DB::raw('CONCAT("' . asset('') . '", pu_pictures.url) AS picture_publication'), DB::raw('CONCAT("' . asset('') . '", u.picture) AS picture_user'), DB::raw('CONCAT("' . asset('') . '",' . ' p.picture_face) AS picture_provider'), DB::raw('CONCAT("' . asset('') . '", ca.picture) AS picture_category'), DB::raw('CONCAT(u.name, " ", u.lastname) AS name_user'), 'u.idfacebook', 'prt.name_type as name_type_provider', 'p.name_provider', 'p.pu_category_id', 'ca.name_category', 'p.ranking as ranking_provider', 't.name_type', 'prt.id as id_type_provider');
         if ($category != null) {
             $data = $data->whereIn('pu_ads.pu_category_id', $category);
         }
         if ($description != null) {
             $data = $data->where('pu_ads.description', 'like', '%' . $description . '%');
         }
         if ($user_id != null) {
             $data = $data->where('pu_ads.user_id', '=', $user_id);
         }
         if ($type != null) {
             $data = $data->where('t.name_type', '=', $type);
         }
         $data = $data->where('pu_ads.flagactive', '=', 1)->skip($this->perpage * ($page - 1))->orderBy('pu_ads.pu_type_id', 'desc')->orderBy('pu_ads.lastupdate', 'desc')->groupBy('pu_ads.id')->take($this->perpage)->get();
         $dataFinish = $data->toArray();
         if ($dataFinish) {
             foreach ($dataFinish as $value) {
                 $likes = PuLikes::wherePuAdId($value['id'])->select(DB::raw('count(id) as likes'))->get();
                 $comments = PuComments::wherePuAdId($value['id'])->select(DB::raw('count(id) as comments'))->get();
                 $valueFinal = ["id" => $value["id"], "idfacebook" => $value["idfacebook"], "pu_type_id" => $value["pu_type_id"], "pu_category_id" => $value["pu_category_id"], "pu_state_id" => $value["pu_state_id"], "user_id" => $value["user_id"], "description" => $value["description"], "date_publish" => $value["date_publish"], "date_expired" => $value["date_expired"], "flagactive" => $value["flagactive"], "datecreate" => $value["datecreate"], "lastupdate" => $value["lastupdate"], "picture_publication" => $value["picture_publication"], "picture_user" => $value["picture_user"], "picture_category" => $value["picture_category"], "name_user" => $value["name_user"], "name_category" => $value["name_category"], "name_type" => $value["name_type"], "likes" => $likes[0]->likes, "comments" => $comments[0]->comments];
                 if ($value['pr_provider_id']) {
                     $score = PrScore::wherePrProviderId($value['pr_provider_id'])->select(DB::raw('count(id) as score'))->get();
                     $providerCategory = Categories::whereId($value['pu_category_id'])->select('name_category', DB::raw('CONCAT("' . asset('') . '", picture) AS picture_category'))->first();
                     $EstadoTipo = $value['name_type_provider'] == PrProviders::Type_Inactivo ? "0" : "1";
                     $valueFinal['provider'] = [['pr_provider_id' => $value['pr_provider_id'], 'id_type_provider' => $value['id_type_provider'], 'name_provider' => $value['name_provider'], 'name_type_provider' => $value['name_type_provider'], 'approved' => $EstadoTipo, "total_users" => $score[0]->score, "score" => $value["ranking_provider"], 'picture_provider' => $value['picture_provider'], 'name_category' => $providerCategory->name_category, 'picture_category' => $providerCategory->picture_category]];
                 } else {
                     $valueFinal['provider'] = [];
                 }
                 $dataFinish1[] = $valueFinal;
             }
         } else {
             $dataFinish1 = [];
         }
         return $dataFinish1;
     } catch (Exception $exc) {
         echo $exc->getTraceAsString();
         exit;
     }
 }
开发者ID:josmel,项目名称:buen,代码行数:42,代码来源:PuAds.php


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