From a28017c4755a1543cce9a8403ab5585478f016a0 Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Tue, 26 Apr 2022 11:15:27 -0700 Subject: [PATCH] approve --- app/Http/Controllers/JoinedController.php | 6 --- app/Http/Livewire/Admin/ListFanlistings.php | 13 ++++-- resources/views/admin/layout.blade.php | 10 ++-- .../livewire/admin/list-fanlistings.blade.php | 6 +-- routes/web.php | 46 +++++++++---------- tests/Pest.php | 5 +- tests/TestCase.php | 2 + 7 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/Http/Controllers/JoinedController.php b/app/Http/Controllers/JoinedController.php index 05cf561..be3274e 100644 --- a/app/Http/Controllers/JoinedController.php +++ b/app/Http/Controllers/JoinedController.php @@ -41,12 +41,6 @@ public function store(StoreJoinedRequest $request) return redirect()->route('admin.joined.index')->with('success', 'Fanlisting added.'); } - public function approve(Joined $joined) - { - $joined->approve(); - return redirect()->route('admin.joined.index')->with('success', 'Fanlisting approved.'); - } - public function show(Joined $joined) { // diff --git a/app/Http/Livewire/Admin/ListFanlistings.php b/app/Http/Livewire/Admin/ListFanlistings.php index 49f8b47..a3f71a6 100644 --- a/app/Http/Livewire/Admin/ListFanlistings.php +++ b/app/Http/Livewire/Admin/ListFanlistings.php @@ -3,7 +3,6 @@ namespace App\Http\Livewire\Admin; use App\Models\Joined; -use Illuminate\Pagination\LengthAwarePaginator; use Livewire\Component; use Livewire\WithPagination; @@ -17,12 +16,20 @@ public function render() { if ($this->class == 'joined') { $fanlistings = auth_collective()->joined()->paginate(8); - } else if ($this->class == 'owned') { - // + } elseif ($this->class == 'owned') { + // TODO: add owned class } return view('livewire.admin.list-fanlistings', [ 'fanlistings' => $fanlistings, ]); } + + public function approve(Joined $fl) + { + if ($fl->approved == false) { + $fl->approved = true; + $fl->save(); + } + } } diff --git a/resources/views/admin/layout.blade.php b/resources/views/admin/layout.blade.php index ef9c804..b5f89b3 100644 --- a/resources/views/admin/layout.blade.php +++ b/resources/views/admin/layout.blade.php @@ -41,15 +41,15 @@ @if (session()->has('success')) -

{{ session()->get('success') }}

+

{{ session()->get('success') }}

@endif @if (session()->has('error')) -

{{ session()->get('error') }}

+

{{ session()->get('error') }}

@endif @if (session()->has('warning')) -

{{ session()->get('warning') }}

+

{{ session()->get('warning') }}

@endif @yield('content') @@ -58,5 +58,9 @@ + \ No newline at end of file diff --git a/resources/views/livewire/admin/list-fanlistings.blade.php b/resources/views/livewire/admin/list-fanlistings.blade.php index b25eabc..bc3c918 100644 --- a/resources/views/livewire/admin/list-fanlistings.blade.php +++ b/resources/views/livewire/admin/list-fanlistings.blade.php @@ -23,10 +23,10 @@ - @if ($class == 'joined') - + @if ($class == 'joined' && $fl->approved == false) + @elseif ($class == 'owned') View @endif diff --git a/routes/web.php b/routes/web.php index d6a56d9..e0be7ef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,34 +18,32 @@ Route::redirect('/fanatic', '/fanatic/login')->middleware('guest'); Route::middleware('guest')->group(function () { - Route::get('/fanatic/login', [SessionsController::class, 'create']) - ->name('admin.sessions.create'); - Route::get('/fanatic/install', [CollectiveController::class, 'create']) - ->name('admin.collectives.create'); - Route::post('/fanatic', [CollectiveController::class, 'store']) - ->name('admin.collectives.store'); + Route::get('/fanatic/login', [SessionsController::class, 'create']) + ->name('admin.sessions.create'); + Route::get('/fanatic/install', [CollectiveController::class, 'create']) + ->name('admin.collectives.create'); + Route::post('/fanatic', [CollectiveController::class, 'store']) + ->name('admin.collectives.store'); }); Route::post('/fanatic', [SessionsController::class, 'store'])->name('admin.sessions.store'); Route::middleware('auth')->group(function () { - Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('admin.dashboard'); - Route::delete('/fanatic', [SessionsController::class, 'destroy'])->name('admin.sessions.destroy'); + Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('admin.dashboard'); + Route::delete('/fanatic', [SessionsController::class, 'destroy'])->name('admin.sessions.destroy'); - Route::get('/fanatic/joined', [JoinedController::class, 'index']) - ->name('admin.joined.index'); - Route::get('/fanatic/joined/create', [JoinedController::class, 'create']) - ->name('admin.joined.create'); - Route::post('/fanatic/joined', [JoinedController::class, 'store']) - ->name('admin.joined.store'); - Route::patch('/fanatic/joined/{joined}/approve', [JoinedController::class, 'approve']) - ->name('admin.joined.approve'); - Route::get('/fanatic/joined/{joined}', [JoinedController::class, 'show']) - ->name('admin.joined.show'); - Route::get('/fanatic/joined/{joined}/edit', [JoinedController::class, 'edit']) - ->name('admin.joined.edit'); - Route::patch('/fanatic/joined/{joined}', [JoinedController::class, 'update']) - ->name('admin.joined.update'); - Route::delete('/fanatic/joined/{joined}', [JoinedController::class, 'destroy']) - ->name('admin.joined.destroy'); + Route::get('/fanatic/joined', [JoinedController::class, 'index']) + ->name('admin.joined.index'); + Route::get('/fanatic/joined/create', [JoinedController::class, 'create']) + ->name('admin.joined.create'); + Route::post('/fanatic/joined', [JoinedController::class, 'store']) + ->name('admin.joined.store'); + Route::get('/fanatic/joined/{joined}', [JoinedController::class, 'show']) + ->name('admin.joined.show'); + Route::get('/fanatic/joined/{joined}/edit', [JoinedController::class, 'edit']) + ->name('admin.joined.edit'); + Route::patch('/fanatic/joined/{joined}', [JoinedController::class, 'update']) + ->name('admin.joined.update'); + Route::delete('/fanatic/joined/{joined}', [JoinedController::class, 'destroy']) + ->name('admin.joined.destroy'); }); diff --git a/tests/Pest.php b/tests/Pest.php index 5d3a73b..e5a4460 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,8 @@ in('Feature'); +uses(Tests\TestCase::class, RefreshDatabase::class, WithFaker::class)->in('Feature'); /* |-------------------------------------------------------------------------- diff --git a/tests/TestCase.php b/tests/TestCase.php index 2932d4a..37ff173 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,4 +7,6 @@ abstract class TestCase extends BaseTestCase { use CreatesApplication; + + protected $seed = true; }