Declare sharable user instance in master view

This commit is contained in:
Pig Fang 2019-03-31 09:08:31 +08:00
parent c57a8c8316
commit d9efa1d5ff
10 changed files with 8 additions and 27 deletions

View File

@ -14,7 +14,6 @@ class ClosetController extends Controller
public function index()
{
return view('user.closet')
->with('user', Auth::user())
->with('extra', ['unverified' => option('require_verification') && ! $user->verified]);
}

View File

@ -52,11 +52,7 @@ class PlayerController extends Controller
public function index()
{
$user = Auth::user();
return view('user.player')
->with('players', $user->players->toArray())
->with('user', $user)
->with('extra', [
'rule' => trans('user.player.player-name-rule.'.option('player_name_rule')),
'length' => trans(

View File

@ -40,11 +40,6 @@ class ReportController extends Controller
return json(trans('skinlib.report.success'), 0);
}
public function viewTrack()
{
return view('user.report', ['user' => auth()->user()]);
}
public function track()
{
return Report::where('reporter', auth()->id())

View File

@ -32,7 +32,6 @@ class UserController extends Controller
$user = Auth::user();
return view('user.index')->with([
'user' => $user,
'statistics' => [
'players' => $this->calculatePercentageUsed($user->players->count(), option('score_per_player')),
'storage' => $this->calculatePercentageUsed($user->getStorageUsed(), option('score_per_storage')),
@ -160,7 +159,6 @@ class UserController extends Controller
{
$user = Auth::user();
return view('user.profile')
->with('user', $user)
->with('extra', [
'unverified' => option('require_verification') && ! $user->verified,
'admin' => $user->isAdmin(),

View File

@ -14,6 +14,10 @@
@yield('style')
</head>
@php
$user = auth()->user();
@endphp
<body class="hold-transition {{ option('color_scheme') }} sidebar-mini">
<div class="wrapper">

View File

@ -49,7 +49,7 @@ Route::group([
Route::get('/score-info', 'UserController@scoreInfo');
Route::post('/sign', 'UserController@sign');
Route::get('/reports', 'ReportController@viewTrack');
Route::view('/reports', 'user.report');
Route::get('/report-list', 'ReportController@track');
// Profile

View File

@ -24,7 +24,7 @@ class ClosetControllerTest extends TestCase
public function testIndex()
{
$this->get('/user/closet')->assertViewHas('user');
$this->get('/user/closet')->assertViewIs('user.closet');
}
public function testGetClosetData()

View File

@ -21,9 +21,7 @@ class PlayerControllerTest extends TestCase
public function testIndex()
{
$this->get('/user/player?pid=5')
->assertViewHas('players')
->assertViewHas('user');
$this->get('/user/player?pid=5')->assertViewIs('user.player');
}
public function testListAll()

View File

@ -71,12 +71,6 @@ class ReportControllerTest extends TestCase
]);
}
public function testViewTrack()
{
$user = factory(User::class)->create();
$this->actAs($user)->get('/user/reports')->assertViewIs('user.report');
}
public function testTrack()
{
$user = factory(User::class)->create();

View File

@ -21,7 +21,6 @@ class UserControllerTest extends TestCase
$this->actAs($user)
->get('/user')
->assertViewHas('user')
->assertViewHas('statistics')
->assertSee((new Parsedown())->text(option_localized('announcement')))
->assertSee((string) $user->score);
@ -200,9 +199,7 @@ class UserControllerTest extends TestCase
public function testProfile()
{
$this->actAs('normal')
->get('/user/profile')
->assertViewHas('user');
$this->actAs('normal')->get('/user/profile')->assertViewIs('user.profile');
}
public function testHandleProfile()