當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。