-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the issue of not showing menubar in the dashboard
- Loading branch information
1 parent
41964b6
commit efb92ea
Showing
7 changed files
with
119 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Backend; | ||
|
||
use App\Models\Category; | ||
use App\Models\Comment; | ||
use App\Models\Feedback; | ||
use Illuminate\Contracts\View\View; | ||
use Livewire\Component; | ||
|
||
class Dashboard extends Component | ||
{ | ||
public function render(): View | ||
{ | ||
$categories = Category::query()->withCount('articles')->get()->sortByDesc('articles_count'); | ||
$latestComments = Comment::query()->with('user')->latest()->take(3)->get(); | ||
$latestFeedbacks = Feedback::query()->where('is_closed', 0)->take(3)->get(); | ||
|
||
return view( | ||
'livewire.backend.dashboard', | ||
compact('categories', 'latestComments', 'latestFeedbacks') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,3 @@ | ||
<x-backend> | ||
<div class="flex flex-row"> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center">Latest Comments</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($latestComments as $comment) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$comment->user->name}}</span><br> | ||
<span class="text-slate-400">{{$comment->createdAtHumanDiff}}</span><br> | ||
{{$comment->content}} | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center">Latest Feedback</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($latestFeedbacks as $feedback) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$feedback->name}}</span><br> | ||
<span class="text-slate-400">{{$feedback->createdAtHumanDiff}}</span><br> | ||
{{$feedback->content}} | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
<x-backend.table.td colspan="100" class="text-gray-400 text-center">No new feedback</x-backend.table.td> | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center" colspan="100">Articles Categories</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($categories as $category) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$category->name}}</span> | ||
</x-backend.table.td> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="text-slate-400">{{$category->articles_count}}</span><br> | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
<x-backend.table.td colspan="100" class="text-gray-400 text-center">No new feedback</x-backend.table.td> | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
</div> | ||
<livewire:backend.dashboard/> | ||
</x-backend> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<div class="flex flex-row"> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center">Latest Comments</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($latestComments as $comment) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$comment->user->name}}</span><br> | ||
<span class="text-slate-400">{{$comment->createdAtHumanDiff}}</span><br> | ||
{{$comment->content}} | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center">Latest Feedback</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($latestFeedbacks as $feedback) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$feedback->name}}</span><br> | ||
<span class="text-slate-400">{{$feedback->createdAtHumanDiff}}</span><br> | ||
{{$feedback->content}} | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
<x-backend.table.td colspan="100" class="text-gray-400 text-center">No new feedback</x-backend.table.td> | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
<div class="basis-1/3"> | ||
<x-backend.table> | ||
<x-slot name="head"> | ||
<tr> | ||
<x-backend.table.th class="text-center" colspan="100">Articles Categories</x-backend.table.th> | ||
</tr> | ||
</x-slot> | ||
|
||
<x-slot name="body"> | ||
@forelse($categories as $category) | ||
<tr> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="font-medium">{{$category->name}}</span> | ||
</x-backend.table.td> | ||
<x-backend.table.td class="text-gray-600"> | ||
<span class="text-slate-400">{{$category->articles_count}}</span><br> | ||
</x-backend.table.td> | ||
</tr> | ||
@empty | ||
<x-backend.table.td colspan="100" class="text-gray-400 text-center">No new feedback</x-backend.table.td> | ||
@endforelse | ||
</x-slot> | ||
</x-backend.table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Livewire\Backend; | ||
|
||
use App\Livewire\Backend\Dashboard; | ||
use Livewire\Livewire; | ||
use Tests\TestCase; | ||
|
||
class DashboardTest extends TestCase | ||
{ | ||
public function testRender() | ||
{ | ||
Livewire::test(Dashboard::class) | ||
->assertOk() | ||
->assertViewIs('livewire.backend.dashboard') | ||
->assertViewHas('categories') | ||
->assertViewHas('latestComments') | ||
->assertViewHas('latestFeedbacks'); | ||
} | ||
} |