blessing-skin-server/app/Http/View/Composers/UserMenuComposer.php
2020-03-18 10:33:07 +08:00

33 lines
741 B
PHP

<?php
namespace App\Http\View\Composers;
use Blessing\Filter;
use Illuminate\Http\Request;
use Illuminate\View\View;
class UserMenuComposer
{
/** @var Request */
protected $request;
/** @var Filter */
protected $filter;
public function __construct(Request $request, Filter $filter)
{
$this->request = $request;
$this->filter = $filter;
}
public function compose(View $view)
{
$user = auth()->user();
$avatarUrl = route('avatar.user', ['uid' => $user->uid, 'size' => 36]);
$avatar = $this->filter->apply('user_avatar', $avatarUrl, [$user]);
$cli = $this->request->is('admin', 'admin/*');
$view->with(compact('user', 'avatar', 'cli'));
}
}