完善访问统计

This commit is contained in:
2020-09-24 14:36:54 +08:00
parent 7e7d847ef0
commit 2ff6a2802a
3 changed files with 17 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ 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;
@@ -17,6 +18,12 @@ class Controller extends BaseController
public function __construct()
{
LogModel::create([
'ip' => request()->ip(),
'url' => request()->url(),
]);
//顶部分类
$categorys = Category::where('parent_id', 0)
->where('status', 1)
@@ -25,10 +32,15 @@ class Controller extends BaseController
->orderBy('order', 'asc')
->get();
$links = Link::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);
}
}