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


PHP Category::whereSlug方法代码示例

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


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

示例1: index

 /**
  * Display a listing of categories and the category members (parent-children) and their social media.
  *
  * @return Response
  */
 public function index($slug)
 {
     // get links in footer
     $linksArr = \App\Links::orderBy('rank', 'ASC')->lists('link', 'name');
     if ($slug != 'all') {
         $catObj = Category::whereSlug($slug)->first();
         if (is_null($catObj)) {
             \Session::flash('message', 'Invalid category');
             return redirect('/socialmedia/all');
         }
         $catPathArr = $catObj->getCategoryPath($slug);
         $catArr = $catObj->getChildren($catObj->id);
     } else {
         $catPathArr = array();
         $catObj = new Category();
         $catArr = $catObj->getParents();
     }
     $getChildren = $this->getChildrenBool($catPathArr, $slug, $catObj);
     // eg. get the teammates on the Lakers, don't get teams in the Pacific Coast division
     if ($getChildren) {
         $memberArr = $this->memberObj->getMembersWithinSingleCategory($catObj->id);
         list($memberArr, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($memberArr);
         return view('socialmedia.child', compact('memberArr', 'contentArr', 'catPathArr', 'linksArr'));
     } else {
         $parentArr['contentArr'] = [];
         foreach ($catArr as $catId => $catName) {
             $memberArr = $this->memberObj->getMembersWithinSingleCategory($catId);
             $tmpMemberArr = array($memberArr[0]);
             list(, $contentArr) = $this->memberSocialObj->getSocialMediaWithMemberIds($tmpMemberArr);
             $parentArr['memberArr'][$catId] = $memberArr;
             $parentArr['contentArr'] = $parentArr['contentArr'] + $contentArr;
         }
         return view('socialmedia.parent', compact('parentArr', 'catArr', 'catPathArr', 'linksArr'));
     }
 }
开发者ID:nowarena,项目名称:homestead,代码行数:40,代码来源:SocialMediaController.php

示例2: findByCategory

 /**
  * Find all tricks for the category that matches the given slug.
  *
  * @param string $slug
  * @param int    $perPage
  *
  * @return array
  */
 public function findByCategory($slug, $perPage = self::PAGE_SIZE)
 {
     $category = $this->category->whereSlug($slug)->first();
     if (is_null($category)) {
         throw new CategoryNotFoundException('The category "' . $slug . '" does not exist!');
     }
     $tricks = $category->tricks()->orderBy('created_at', 'DESC')->paginate($perPage);
     return [$category, $tricks];
 }
开发者ID:wmk223,项目名称:site,代码行数:17,代码来源:TrickRepository.php

示例3: fetch_status_history

 public static function fetch_status_history($category_slug)
 {
     $json = [];
     $category = Category::whereSlug($category_slug)->first();
     $device_statuses = DeviceStatus::all();
     foreach ($device_statuses as $device_status) {
         if ($device_status->device->category_id == $category->id) {
             $json[] = ['device_slug' => $device_status->device->slug, 'device_name' => $device_status->device->name, 'user_slug' => $device_status->user->id, 'user_name' => $device_status->user->name, 'status_label' => $device_status->status->status, 'status_descrip' => $device_status->status->description, 'created_at' => date('m/d/Y h:i A', strtotime($device_status->created_at))];
         }
     }
     return json_encode($json);
 }
开发者ID:encry2024,项目名称:inv_5_2,代码行数:12,代码来源:Category.php

示例4: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     // Route Bindings
     $router->bind('categories', function ($value) {
         return Category::whereSlug($value)->first();
     });
     $router->bind('posts', function ($value) {
         return Post::whereSlug($value)->first();
     });
     $router->bind('author', function ($value) {
         return User::whereName($value)->first();
     });
     parent::boot($router);
 }
开发者ID:shempignon,项目名称:laravel-5-blog-mvc,代码行数:20,代码来源:RouteServiceProvider.php

示例5: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $this->bind('package', function ($slug) {
         return Package::with('photos')->whereSlug($slug)->firstOrFail();
     });
     $this->bind('category', function ($slug) {
         return Category::whereSlug($slug)->firstOrFail();
     });
     $this->bind('packages', function ($id) {
         return Package::findOrFail($id);
     });
     $this->bind('categories', function ($id) {
         return Category::findOrFail($id);
     });
     parent::boot($router);
 }
开发者ID:marktimbol,项目名称:eclipse,代码行数:22,代码来源:RouteServiceProvider.php

示例6: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param \Illuminate\Routing\Router $router
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('user', function ($value) {
         return \App\User::whereSlug($value)->firstOrFail();
     });
     $router->bind('category', function ($value) {
         return \App\Category::whereSlug($value)->firstOrFail();
     });
     $router->bind('event', function ($value) {
         return \App\Event::whereSlug($value)->firstOrFail();
     });
     $router->bind('city', function ($value) {
         return \App\City::where('iata', $value)->firstOrFail();
     });
     $router->bind('subscriber', function ($value) {
         return \App\Subscriber::where('token', $value)->firstOrFail();
     });
     parent::boot($router);
 }
开发者ID:EMT,项目名称:see-do,代码行数:26,代码来源:RouteServiceProvider.php

示例7: postCreate

 /**
  * 创建分类 
  *
  * @param string $value 
  *
  * @return Response
  */
 public function postCreate()
 {
     $rules = array('name' => 'required', 'slug' => 'regex:/^[a-zA-Z 0-9_-]+$/', 'parent_id' => 'integer');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // 检测分类名
     if (Category::whereName(Input::get('name'))->count()) {
         return Redirect::back()->withMessage("分类 '" . Input::get('name') . "' 已经存在!")->withColor('danger')->withInput(Input::all());
     }
     //检测别名
     if (Input::get('slug') && Category::whereSlug(Input::get('slug'))->count()) {
         return Redirect::back()->withMessage("分类别名 '" . Input::get('slug') . "' 已经存在!")->withColor('danger')->withInput(Input::all());
     }
     // 创建分类
     $category = new Category();
     $category->name = Input::get('name');
     $category->slug = str_replace(' ', '', snake_case(Input::get('slug')));
     $category->parent = Input::get('parent_id');
     $category->description = Input::get('description');
     $category->save();
     return Redirect::back()->withMessage("分类 '{$category->name}' 添加成功!");
 }
开发者ID:jacobcyl,项目名称:writor,代码行数:31,代码来源:CategoryController.php

示例8: retrieveAvailableDevices

 public static function retrieveAvailableDevices($category_slug, $request)
 {
     $count = 0;
     $category = Category::whereSlug($category_slug)->first();
     $devices = Device::with(['category', 'information'])->where('category_id', $category->id)->where('owner_id', 0);
     $devices = $devices->where('name', 'LIKE', '%' . $request->get('filter') . '%')->paginate(25);
     $devices->setPath('available_devices');
     return view('devices.available_devices', compact('category', 'devices', 'count'));
 }
开发者ID:encry2024,项目名称:inv_5_2,代码行数:9,代码来源:Device.php

示例9: getCategory

 public function getCategory($slug)
 {
     $category = Category::whereSlug($slug)->firstOrFail();
     $products = $category->product()->paginate(12);
     return view('front.home', compact('products'));
 }
开发者ID:fransiskusbenny,项目名称:larashop,代码行数:6,代码来源:FrontController.php

示例10: array

Route::get('/article/detail/{id}', array('uses' => 'ArticleController@showPublic'));
Route::get('/index', function () {
    $coupons = Coupon::all();
    return View::make('index')->with('coupons', $coupons);
});
Route::get('/admin', 'UserController@getAdminLogin');
Route::post('/admin', 'UserController@postAdminLogin');
Route::get('/logout', 'UserController@getLogout');
Route::get('/admin/dashboard', function () {
    return view('admin.content');
});
Route::model('articles', 'Article');
Route::model('merchants', 'Merchant');
Route::model('coupons', 'Coupon');
Route::model('categories', 'Category');
Route::bind('articles', function ($value, $route) {
    return App\Article::whereSlug($value)->first();
});
Route::bind('merchants', function ($value, $route) {
    return App\Merchant::whereSlug($value)->first();
});
Route::bind('coupons', function ($value, $route) {
    return App\Coupon::whereSlug($value)->first();
});
Route::bind('categories', function ($value, $route) {
    return App\Category::whereSlug($value)->first();
});
Route::resource('admin/article', 'ArticleController');
Route::resource('admin/merchant', 'MerchantController');
Route::resource('admin/coupon', 'CouponController');
Route::resource('admin/category', 'CategoryController');
开发者ID:sientong,项目名称:tagin,代码行数:31,代码来源:routes.php

示例11: viewCategoryStatusesHistory

 public function viewCategoryStatusesHistory($category_slug)
 {
     $category = Category::whereSlug($category_slug)->first();
     return view('category.device_statuses', compact('category'));
 }
开发者ID:encry2024,项目名称:inv_5_2,代码行数:5,代码来源:CategoryController.php

示例12: setCategories

 public static function setCategories($post, $category_ids = null, $new_category = null)
 {
     $post->categories()->detach();
     if (isset($new_category) && !empty($new_category)) {
         $current_category = Category::whereSlug(str_slug($new_category))->first();
         if (!$current_category) {
             $new_category = Category::create(['name' => $new_category, 'slug' => str_slug($new_category)]);
             $add_cat_id = $new_category->id;
         } else {
             $add_cat_id = $current_category->id;
         }
         if (is_null($category_ids)) {
             $category_ids = [];
         }
         array_push($category_ids, $add_cat_id);
     }
     if (isset($category_ids)) {
         $post->categories()->attach($category_ids);
     }
 }
开发者ID:ambarsetyawan,项目名称:brewski,代码行数:20,代码来源:Post.php

示例13: scopeOfCategory

 /**
  * All files by slug of category
  */
 public function scopeOfCategory($query, $categorySlug)
 {
     $category = Category::whereSlug($categorySlug)->firstOrFail();
     return $query->whereCategoryId($category->id);
 }
开发者ID:quantbm,项目名称:RimDrive,代码行数:8,代码来源:File.php

示例14: showDefectDev

 public function showDefectDev($category_slug)
 {
     $category = Category::whereSlug($category_slug)->first();
     return view('devices.defective_devices', compact('category'));
 }
开发者ID:encry2024,项目名称:inv_5_2,代码行数:5,代码来源:DeviceController.php

示例15: show

 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($slug)
 {
     $page_size = env('num_per_page');
     //        //method I.               num of queries:  17.
     //        $articles = Category::findBySlug($slug)->articles()->latest()->paginate($page_size);
     //method II: eager loading. num of queries 5
     //http://php.net/manual/en/functions.anonymous.php   "use" to inherit variables from its parent scope
     //whereSlug($slug) equals to where('slug', '=', $slug).
     $articles = \App\Article::with('tags', 'category')->published()->whereHas('category', function ($query) use($slug) {
         $query->whereSlug($slug);
     })->latest()->paginate($page_size);
     $Catname = Category::whereSlug($slug)->firstOrFail()->name;
     return view('blog.cats.show', compact('articles', 'Catname'));
 }
开发者ID:ambarsetyawan,项目名称:laravel5-blog-1,代码行数:20,代码来源:CategoriesController.php


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