47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Advert;
|
|
use App\Models\Article;
|
|
use App\Models\Category;
|
|
use App\Models\Link;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
use Illuminate\Routing\Controller as BaseController;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
class Controller extends BaseController
|
|
{
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
|
|
|
public function __construct()
|
|
{
|
|
//顶部分类
|
|
$categorys = Category::where('parent_id', 0)
|
|
->where('status', 1)
|
|
->where('top_show', 1)
|
|
->select('id', 'title', 'type', 'order', 'article_id')
|
|
->orderBy('order', 'asc')
|
|
->get();
|
|
|
|
$top_advert = Advert::where('category_id', 17)->first();
|
|
|
|
$links = Link::get();
|
|
$manage_users = Article::where('category_id', 21)->latest('sort')->take(3)->get(); //编委会
|
|
$other_users = Article::where('category_id', 22)->latest('sort')->get(); //副主任
|
|
|
|
View::share('other_users', $other_users);
|
|
View::share('manage_users', $manage_users);
|
|
View::share('all_categorys', $categorys);
|
|
View::share('links', $links);
|
|
View::share('top_advert', $top_advert);
|
|
}
|
|
|
|
public function getCategorys()
|
|
{
|
|
$lists = Category::get();
|
|
}
|
|
}
|