本文整理汇总了PHP中app\Category::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::select方法的具体用法?PHP Category::select怎么用?PHP Category::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEdit
public function getEdit($id)
{
$category = Category::select('id', 'name', 'prarent_id')->get()->toArray();
$product = Product::findOrFail($id);
$product_img = Product::findOrFail($id)->pimages()->get()->toArray();
return view('backend.product.edit', compact('category', 'product', 'product_img'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$users = User::select('id')->get();
$products = Product::select('id')->get();
$categories = Category::select('id')->get();
$areas = Area::select('id')->get();
$orders = Order::select('id')->get();
return view('admin.dashboard', compact('users', 'products', 'categories', 'areas', 'orders'));
}
示例3: getViewCat
public function getViewCat($category_id)
{
// $posts = DB::table('posts')
// ->where('category_id', '=', $category_id)
// ->get();
return view('category')
->with('title', 'Blog | Category')
->with('catdescription',Category::select('description')->where('id', $category_id)->first())
->with('posts', Post::where('category_id', '=', $category_id)->paginate(10))
->with('category', Category::all());
}
示例4: create
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$user = Auth::user();
$user_type = $user->user_type;
if ($user_type == 'COMPANY') {
$id_company = $user->id_company;
} else {
$id_company = Session::get('id_company');
}
$categories = Category::select('category_name', 'id_category')->where('id_company', '=', $id_company)->get();
$products = Product::where('id_company', '=', $id_company)->get();
return view("pedidos.novo", compact('products', 'categories'));
}
示例5: categoryId
/**
* Отображаем пагинацией все новости в конкретной категории
*
* @param $id
* @return \Illuminate\View\View
*/
public function categoryId($id)
{
try {
$data = \DB::table('news')->where('category_id', $id)->where('publish', '1')->orderBy('id', 'desc')->paginate(10);
$categoryTitle = Category::select('title')->where('id', $id)->where('publish', 1)->get()[0]->title;
} catch (\ErrorException $e) {
abort(404);
}
// обрезаем 200 символов текста новости
$this->get200Text($data);
$this->title .= ': ' . $categoryTitle . $this->getTitlePagination();
return view('news.list', ['title' => $this->title, 'data' => $data, 'categoryTitle' => $categoryTitle]);
}
示例6: categoryId
/**
* Отображаем пагинацией все статьи в конкретной категории
*
* @param $id
* @return \Illuminate\View\View
*/
public function categoryId($id)
{
// почему-то не работает upd:заработало. спасибо stackoverflow!
//$data = Category::find($id)->articles()->where('publish', '1')->paginate(5);
try {
$data = \DB::table('info')->where('category_id', $id)->where('publish', '1')->where('published_at', '<=', Carbon::now())->orderBy('id', 'desc')->select('title', 'url')->paginate(10);
$categoryTitle = Category::select('title')->where('id', $id)->where('publish', 1)->get()[0]->title;
} catch (\ErrorException $e) {
abort(404);
}
$this->title .= $categoryTitle . $this->getTitlePagination();
return view('articles.list', ['title' => $this->title, 'data' => $data, 'categoryTitle' => $categoryTitle]);
}
示例7: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$table = "company";
if (\Schema::hasTable($table)) {
$main_company = Company::find(1)->toArray();
$categories_menu = \Cache::remember('categories_mothers', 25, function () {
return Category::select('id', 'name')->childsOf('mothers')->actives()->get()->toArray();
});
$menu = [];
foreach ($categories_menu as $value) {
$menu[$value['id']] = $value;
}
\View::share('main_company', $main_company);
\View::share('categories_menu', $menu);
}
}
示例8: getall
public function getall()
{
$categories = Category::select('id', 'cat_name', 'img_url', 'cat_position')->get();
return Response::json($categories);
}
示例9: getCategoryOptions
/**
* @param Category $except
*
* @return CategoriesController
*/
protected function getCategoryOptions($except = null)
{
/** @var \Kalnoy\Nestedset\QueryBuilder $query */
$query = Category::select('id', 'name')->withDepth();
if ($except) {
$query->whereNotDescendantOf($except)->where('id', '<>', $except->id);
}
return $this->makeOptions($query->get());
}
示例10: getRandId
public static function getRandId()
{
$category = Category::select(['id'])->orderByRaw('RAND()')->take(1)->first();
return $category->id;
}
示例11: getCategoryOptions
/**
* @param Category $except
*
* @return CategoriesController
*/
protected function getCategoryOptions($except = null)
{
$query = Category::select('id', 'name')->withDepth();
if ($except) {
$query->whereNotDescendantOf($except)->where('id', '<>', $except->id);
}
return $this->makeOptions($query->get());
}
示例12: propertyCategories
public function propertyCategories()
{
$search = \Input::get('q');
if ($search) {
$categories = \App\Category::select('Categories.*')->join('CategoryLanguages', 'CategoryLanguages.property_id', '=', 'Categories.id')->where('CategoryLanguages.locale', $this->lang)->where('CategoryLanguages.title', 'like', $search . '%')->orderBy('Categories.created_at', 'desc')->paginate($this->limit);
} else {
$categories = \App\Category::orderBy('order', 'asc')->paginate($this->limit);
}
return view('admin.pages.categories', compact('categories'));
}
示例13: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($slug)
{
return view('admin.articles.edit', ['article' => Article::with('tags', 'category')->where('slug', $slug)->firstOrFail(), 'categories' => Category::select('id', 'name')->get(), 'tags' => Tag::select('id', 'name')->get()]);
}
示例14: getEdit
public function getEdit($id)
{
$data = Category::findOrFail($id)->toArray();
$parent = Category::select('id', 'name', 'prarent_id')->get()->toArray();
return view('backend.category.edit', compact('parent', 'data'));
}
示例15: parentsTree
/**
* parentsTree
* Retrieve all the categories parents of one passed through parameter,
* checking data from bottom to top
* @param [int] $id is the id category evaluated
* @param [array] $array is the array to be used out of the model
* @param [array] $fields is the array that contais the table field we want to retrieve
*/
public static function parentsTree($id, &$array, $fields = ['id', 'category_id', 'name'])
{
$categories = Category::select($fields)->where('id', $id)->get()->toArray();
if (is_null($categories)) {
return;
}
foreach ($categories as $value) {
$array[] = $value;
Category::parentsTree($value['category_id'], $array, $fields);
}
return;
}