本文整理汇总了PHP中app\Category::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::all方法的具体用法?PHP Category::all怎么用?PHP Category::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getList
/**
* Get a list of categories
*
* @return static
*/
public function getList()
{
$categories = $this->category->all();
$response = $categories->map(function ($item) {
return ["id" => $item->id, "name" => $item->name];
});
return $response;
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index(Category $category)
{
$categoriesObj = $category->all();
$categoriesArr = $category->getCategoriesArr($categoriesObj);
$parentChildArr = $this->categoryPAndCObj->getHierarchy();
return view('categories.index', compact('categoriesObj', 'parentChildArr', 'categoriesArr'));
}
示例3: edit
public function edit($id)
{
$category = Category::all();
$product = Product::find($id);
$imagepivot = $product->image_product()->where('product_id', $id)->get()->toArray();
return view('admin.products.edit', compact('product', 'category', 'imagepivot'));
}
示例4: all
public function all()
{
$businesses = Business::all();
$categories = Category::all();
$page = "Toutes les entreprises";
return view('businesses', compact('businesses', 'page', 'categories'));
}
示例5: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show(Category $category)
{
//
$blogs = $category->blogs()->paginate(5);
$categories = Category::all();
return view('categories.show', compact('blogs', 'category', 'categories'));
}
示例6: index
/**
* Index page
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$productsCount = Product::all()->count();
$categoriesCount = Category::all()->count();
$usersCount = User::all()->count();
return view('manage.index', compact('productsCount', 'categoriesCount', 'usersCount'));
}
示例7: edit
public function edit($id)
{
$post = Post::whereId($id)->FirstOrFail();
$categories = Category::all();
$selectedCategories = $post->categories->lists('id')->toArray();
return view('backend.posts.edit', compact('post', 'categories', 'selectedCategories'));
}
示例8: __construct
public function __construct()
{
// injecter du code dans une vue, $view <-> au template
View::composer('partials.main_menu', function ($view) {
$view->with('categories', Category::all());
});
}
示例9: getAllFromCache
public static function getAllFromCache()
{
$categories = Cache::rememberForever('categories', function () {
return Category::all();
});
return $categories;
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Category::all()->count() > 0) {
return $next($request);
}
return redirect()->route('courses.index')->withErrors(['message' => 'No existen categorías registradas.']);
}
示例11: edit
public function edit($id)
{
$product = Product::find($id);
$tags = Tag::lists('name', 'id');
$categories = Category::all();
return view('admin.edit', compact('product', 'tags', 'categories'));
}
示例12: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$category = Category::all();
return $category;
// return dd($products); //remove later
//return response()->json(['categories'=>$categories]);
}
示例13: edit
public function edit($id)
{
$displays = $displayss = Display::all();
$categorys = $categoryss = Category::all();
$article = Article::find($id);
return view('admin.articles.edit', ['article' => $article, "categorys" => $categorys, "categoryss" => $categoryss, "displays" => $displays, "displayss" => $displayss]);
}
示例14: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$pageTitle = 'Add New Article';
// Administrator
if (Auth::user()->hasRole(['administrator'])) {
$categories = Category::all();
}
// Department Manager
if (Auth::user()->hasRole(['department_manager'])) {
$department = Auth::user()->departments->first();
$categories = Category::where('department_id', '=', $department->id)->get();
}
// Category Manager
if (Auth::user()->hasRole(['category_manager'])) {
$categories = Category::where('manager', '=', Auth::user()->id);
}
// Article Manager
// Who can write for all categories of department which is allocated.
// Currently, article managers are separately with category managers
if (Auth::user()->hasRole(['article_manager'])) {
$department = Auth::user()->departments->first();
$categories = Category::where('department_id', '=', $department->id)->get();
}
return view('home.articles.create', compact('pageTitle', 'categories'));
}
示例15: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$formats = Format::all();
$categories = Category::all();
$output = array('formats' => $formats, 'categories' => $categories);
return view('user.addBook', compact('output'));
}