當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::whereId方法代碼示例

本文整理匯總了PHP中app\Category::whereId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::whereId方法的具體用法?PHP Category::whereId怎麽用?PHP Category::whereId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::whereId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testUpdateCategory

 /**
  * Category Update test
  *
  * @return void
  */
 public function testUpdateCategory()
 {
     $category = Category::first();
     $toUpdate = ['name' => $this->faker->word . '777'];
     $endpoint = $this->getEndpointWithToken($this->endpoint . '/' . $category->id);
     $this->call('PATCH', $endpoint, $toUpdate);
     //fetch inserted category
     $updated_category = Category::whereId($category->id)->first();
     $this->assertEquals($toUpdate['name'], $updated_category->name);
 }
開發者ID:hootlex,項目名稱:apodeiksi,代碼行數:15,代碼來源:CategoriesApiTest.php

示例2: edit

 public function edit($id)
 {
     $Category = Category::whereId($id)->firstOrFail();
     $levelOnes = Category::all()->where('status', 1)->where('parent_id', null);
     return view('admin.category.edit', compact('Category', 'levelOnes'));
 }
開發者ID:keung725,項目名稱:shop,代碼行數:6,代碼來源:CategoryController.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $category = Category::whereId($id)->firstOrFail();
     $name = $category->name;
     $category->delete();
     return redirect()->route('categories.index')->with('status', 'The category ' . $name . ' has been deleted!');
 }
開發者ID:alidaniel,項目名稱:items,代碼行數:13,代碼來源:CategoriesController.php

示例4: delete

 /**
  * Delete category
  *
  * @param $id
  */
 public function delete($id)
 {
     Category::whereId($id)->delete();
 }
開發者ID:slawisha,項目名稱:computer-shop,代碼行數:9,代碼來源:CategoryRepository.php

示例5: setTitleAttribute

 public function setTitleAttribute($value)
 {
     $autoCategories = ['transport', 'cars', 'motorcycles'];
     $realtyCategories = ['apartment', 'houses', 'land', 'commercial_realty'];
     $request = Request::all();
     $categorySlug = Category::whereId($request['category_id'])->first()->slug;
     if (in_array($categorySlug, $autoCategories)) {
         $autoModel = AutoModel::whereId(Request::input('model'))->first();
         $value = sprintf('%s %s, %d', $autoModel->parent->title, $autoModel->title, $request['year']);
     }
     if (in_array($categorySlug, $realtyCategories)) {
         switch ($categorySlug) {
             case 'apartment':
                 $value = sprintf("%s %d-к квартиру, %s м², %d/%d эт.", $request['type_of_ad'], $request['num_of_rooms'], $request['square'], $request['floor'], $request['num_of_floors']);
                 break;
             case 'houses':
                 $value = sprintf("%s дом, %s м²", $request['type_of_ad'], $request['square']);
                 break;
             case 'land':
                 $value = sprintf("%s участок, %s сот.", $request['type_of_ad'], $request['square'] / 100);
                 break;
             case 'commercial_realty':
                 $value = sprintf("%s помещение, %s м²", $request['type_of_ad'], $request['square']);
                 break;
         }
     }
     $this->attributes['title'] = $value;
 }
開發者ID:elberd,項目名稱:maoh,代碼行數:28,代碼來源:Ad.php


注:本文中的app\Category::whereId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。