first commit
This commit is contained in:
38
app/Http/Controllers/Controller.php
Normal file
38
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Advert;
|
||||
use App\Models\Category;
|
||||
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('status', 1)
|
||||
->whereIn('type', [Category::TYPE_ARTICLE, Category::TYPE_SHOW])
|
||||
->where('top_show', 1)
|
||||
->orderBy('order', 'desc')
|
||||
->select('id', 'title')
|
||||
->get();
|
||||
|
||||
//地步友情链接
|
||||
if (url()->current() == route('index.index')){
|
||||
$adverts = Advert::where('category_id', 72)->get();
|
||||
}else{
|
||||
$adverts = Advert::where('category_id', 73)->get();
|
||||
}
|
||||
View::share('all_categorys', $categorys);
|
||||
View::share('adverts', $adverts);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user