Files
new_caauto/app/Http/Controllers/Controller.php
2020-09-24 14:36:54 +08:00

47 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Category;
use App\Models\Link;
use App\Models\Log as LogModel;
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()
{
LogModel::create([
'ip' => request()->ip(),
'url' => request()->url(),
]);
//顶部分类
$categorys = Category::where('parent_id', 0)
->where('status', 1)
->where('top_show', 1)
->select('id', 'title', 'type', 'order', 'article_id')
->orderBy('order', 'asc')
->get();
$links = Link::get();
$all_count = 202565 + LogModel::count();
$day_count = 2586 + LogModel::whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()])->count();
View::share('all_categorys', $categorys);
View::share('links', $links);
View::share('all_count', $all_count);
View::share('day_count', $day_count);
}
}