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


PHP Category::getAll方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->middleware('auth');
     if (Auth::user()) {
         $this->favs = Fav::getAll();
         $this->categories = Category::getAll();
     }
 }
开发者ID:brslv,项目名称:favdit,代码行数:8,代码来源:FavsController.php

示例2: questions

 public function questions()
 {
     if (Auth::check()) {
         $comments = Comment::whereHas('ad', function ($query) {
             $query->where(['author_id' => Auth::user()->id, 'answer_to' => null]);
         })->orWhereHas('answerTo', function ($query) {
             $query->where('author_id', Auth::user()->id);
         })->orderBy('created_at', 'desc')->get();
         return view('profile.questions', ['categories' => Category::getAll(), 'comments' => $comments]);
     } else {
         return redirect('/');
     }
 }
开发者ID:elberd,项目名称:maoh,代码行数:13,代码来源:ProfileController.php

示例3: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer(['layout', 'errors.layout', 'sub.filters'], function ($view) {
         $new_questions = 0;
         if (Auth::check()) {
             $new_questions = Comment::where('is_viewed', false)->whereHas('ad', function ($query) {
                 $query->where(['author_id' => Auth::user()->id, 'answer_to' => null]);
             })->orWhereHas('answerTo', function ($query) {
                 $query->where(['author_id' => Auth::user()->id]);
             })->where('is_viewed', false)->count();
         }
         $view->with(['new_questions' => $new_questions, 'categories' => Category::getAll()]);
     });
 }
开发者ID:elberd,项目名称:maoh,代码行数:19,代码来源:ComposerServiceProvider.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(StoreAdRequest $request, $id)
 {
     $ad = Ad::findOrFail($id);
     if (Gate::allows('update', $ad)) {
         $isFree = $request['is_free'] == 'on';
         $ad->update(['title' => $request['title'], 'text' => $request['text'], 'author_name' => $request['name'], 'phone' => $request['phone'], 'category_id' => $request['category_id'], 'city_id' => $request['city_id'], 'price' => $isFree ? 0 : $request['price'], 'is_free' => $isFree]);
         /*
          *   Store the ad's images
          */
         if ($request->has('images')) {
             $imagesArr = [];
             foreach ($request['images'] as $image) {
                 $imagePaths = explode('|', $image);
                 $imagesArr[] = ['ad_id' => $ad->id, 'small' => $imagePaths[0], 'big' => $imagePaths[1]];
             }
             AdImage::insert($imagesArr);
         }
         /*
          *   Update the ad's auto extra properties if received
          */
         if ($request->has('make')) {
             $autoExtraProperties = AutoExtraProperties::where('ad_id', $ad->id)->first();
             $autoExtraProperties->update(['model_id' => $request['model'], 'year' => $request['year'], 'capacity' => $request['capacity'], 'engine_type' => $request['engine_type'], 'transmission' => $request['transmission'], 'mileage' => $request['mileage'], 'power' => $request['power']]);
         }
         /*
          *   Update the ad's realty extra properties if received
          */
         if ($request->has('type_of_ad')) {
             $realtyExtraProperties = RealtyExtraProperties::where('ad_id', $ad->id)->first();
             $realtyExtraProperties->update(['type' => $request['type_of_ad'], 'lease' => $request['lease'], 'num_of_rooms' => $request['num_of_rooms'], 'square' => $request['square'], 'floor' => $request['floor'], 'num_of_floors' => $request['num_of_floors']]);
         }
         return view('publish', ['categories' => Category::getAll(), 'regions' => Region::getAllWithCities(), 'ad' => $ad, 'updated' => true]);
     } else {
         return redirect('/');
     }
 }
开发者ID:elberd,项目名称:maoh,代码行数:43,代码来源:AdController.php

示例5: contacts

 public function contacts()
 {
     return view('static.contacts', ['categories' => Category::getAll()]);
 }
开发者ID:elberd,项目名称:maoh,代码行数:4,代码来源:StaticPagesController.php


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