refactor: replace CreateAction with CreateSessionAction and update user query for active students in class session pages
This commit is contained in:
parent
2a8412ff60
commit
5f601d8cba
@ -3,7 +3,7 @@
|
|||||||
namespace App\Filament\Resources\Learning\ClassSessions\Pages;
|
namespace App\Filament\Resources\Learning\ClassSessions\Pages;
|
||||||
|
|
||||||
use App\Filament\Actions\BackAction;
|
use App\Filament\Actions\BackAction;
|
||||||
use App\Filament\Actions\Cheerful\CreateAction;
|
use App\Filament\Resources\Learning\ClassSessions\Actions\CreateSessionAction;
|
||||||
use App\Filament\Resources\Learning\ClassSessions\Actions\DeleteSessionAction;
|
use App\Filament\Resources\Learning\ClassSessions\Actions\DeleteSessionAction;
|
||||||
use App\Filament\Resources\Learning\ClassSessions\Actions\EditSessionAction;
|
use App\Filament\Resources\Learning\ClassSessions\Actions\EditSessionAction;
|
||||||
use App\Filament\Resources\Learning\ClassSessions\Actions\GenerateSessionsAction;
|
use App\Filament\Resources\Learning\ClassSessions\Actions\GenerateSessionsAction;
|
||||||
@ -26,7 +26,6 @@
|
|||||||
use Filament\Resources\Pages\Page;
|
use Filament\Resources\Pages\Page;
|
||||||
use Filament\Schemas\Components\Grid;
|
use Filament\Schemas\Components\Grid;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Attributes\Computed;
|
use Livewire\Attributes\Computed;
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ public function course(): Course
|
|||||||
public function sessions(): Collection
|
public function sessions(): Collection
|
||||||
{
|
{
|
||||||
$totalActiveStudents = Student::query()
|
$totalActiveStudents = Student::query()
|
||||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
->whereHas('user', fn ($q) => $q->active())
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return $this->course->classSessions()
|
return $this->course->classSessions()
|
||||||
@ -136,22 +135,7 @@ protected function getHeaderActions(): array
|
|||||||
|
|
||||||
GenerateSessionsAction::make(),
|
GenerateSessionsAction::make(),
|
||||||
|
|
||||||
CreateAction::make()
|
CreateSessionAction::make(),
|
||||||
->label('Tambah')
|
|
||||||
->modalHeading('Tambah Sesi')
|
|
||||||
->modalSubmitActionLabel('Simpan')
|
|
||||||
->modalCancelActionLabel('Batal')
|
|
||||||
->schema(fn (Schema $schema) => $this->form($schema))
|
|
||||||
->mutateDataUsing(function (array $data): array {
|
|
||||||
$data['course_id'] = $this->courseId;
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
})
|
|
||||||
->extraModalFooterActions(fn (CreateAction $action): array => [
|
|
||||||
$action->makeModalSubmitAction('createAnother', arguments: ['another' => true])
|
|
||||||
->label('Simpan dan Tambah Lagi'),
|
|
||||||
])
|
|
||||||
->modalWidth(Width::TwoExtraLarge),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public function form(Schema $schema): Schema
|
|||||||
public function todaySessions(): Collection
|
public function todaySessions(): Collection
|
||||||
{
|
{
|
||||||
$totalActiveStudents = Student::query()
|
$totalActiveStudents = Student::query()
|
||||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
->whereHas('user', fn ($q) => $q->active())
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return ClassSession::query()
|
return ClassSession::query()
|
||||||
@ -118,7 +118,7 @@ public function courses(): Collection
|
|||||||
}
|
}
|
||||||
|
|
||||||
$totalActiveStudents = Student::query()
|
$totalActiveStudents = Student::query()
|
||||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
->whereHas('user', fn ($q) => $q->active())
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
return $query->get()
|
return $query->get()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user