本文整理汇总了PHP中app\Category::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::count方法的具体用法?PHP Category::count怎么用?PHP Category::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(CategoryRequest $request)
{
$category = new Category();
// if ($request->hasFile('image'))
// {
// $image = $request->file('image')->getClientOriginalName();
// $request->file('image')->move('img/categories/', $image);
// }
// else
// {
// $image = 'no-image';
// }
$count = $category->count();
if ($request->sort_id > 0) {
$category->sort_id = $request->sort_id;
} else {
$category->sort_id = ++$count;
}
$category->section_id = $request->section_id;
$category->title = $request->title;
$category->slug = !empty($request->slug) ? $request->slug : str_slug($request->title);
$category->image = $request->image;
$category->title_description = $request->title_description;
$category->meta_description = $request->meta_description;
$category->text = $request->text;
if ($request->status == 'on') {
$category->status = 1;
} else {
$category->status = 0;
}
$category->save();
return redirect('/admin/categories')->with('status', 'Категория добавлена!');
}
示例2: index
public function index()
{
$article_count = Article::count();
$category_count = Category::count();
$tag_count = Tag::count();
$user_count = User::count();
return view('admin.console', compact('article_count', 'category_count', 'tag_count', 'user_count'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
//App::setLocale('kh');
//return trans('administrators.dashboard');
//$user = Auth::user();
//return $user->toJson();
return View('admin.dashboard')->with(['user_total' => \App\User::count(), 'content_total' => \App\Content::count(), 'category_total' => \App\Category::count(), 'slider_total' => \App\Slider::count()]);
}
示例4: composeDashboard
private function composeDashboard()
{
view()->composer('admin.index', function ($view) {
$numArticle = \App\Article::count();
$numCategory = \App\Category::count();
$numTag = \App\Tag::count();
$numProject = \App\Project::count();
$numMessage = \App\Message::count();
$view->with(compact('numArticle', 'numCategory', 'numTag', 'numProject', 'numMessage'));
});
}
示例5: getCreate
public function getCreate()
{
if (\Entrust::hasRole('Admin')) {
if (Category::count()) {
return view('a.productscreate')->with('cato', Category::lists('name', 'id'))->with('products', Product::all());
} else {
return redirect('admin/categories/view');
}
}
return redirect('admin')->with('flash_message', 'You dont have permission to access create product page');
}
示例6: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts_published = Post::published()->count();
$posts_editing = Post::where('published', 'uc')->count();
$posts_sticky = Post::where('is_sticky', 'on')->count();
$posts = Post::count();
$users = User::count();
$jobs = Job::count();
$questions = Question::count();
$categories = Category::count();
return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
}
示例7: boot
protected static function boot()
{
parent::boot();
static::addGlobalScope('category', function (Builder $builder) {
$builder->where('is_topic', 0)->where('is_ads', 0);
});
Category::creating(function ($category) {
if (!$category->order) {
$category->order = Category::count() + 1;
}
});
}