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;
|
||||
|
||||
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\EditSessionAction;
|
||||
use App\Filament\Resources\Learning\ClassSessions\Actions\GenerateSessionsAction;
|
||||
@ -26,7 +26,6 @@
|
||||
use Filament\Resources\Pages\Page;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Attributes\Computed;
|
||||
|
||||
@ -55,7 +54,7 @@ public function course(): Course
|
||||
public function sessions(): Collection
|
||||
{
|
||||
$totalActiveStudents = Student::query()
|
||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
||||
->whereHas('user', fn ($q) => $q->active())
|
||||
->count();
|
||||
|
||||
return $this->course->classSessions()
|
||||
@ -136,22 +135,7 @@ protected function getHeaderActions(): array
|
||||
|
||||
GenerateSessionsAction::make(),
|
||||
|
||||
CreateAction::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),
|
||||
CreateSessionAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ public function form(Schema $schema): Schema
|
||||
public function todaySessions(): Collection
|
||||
{
|
||||
$totalActiveStudents = Student::query()
|
||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
||||
->whereHas('user', fn ($q) => $q->active())
|
||||
->count();
|
||||
|
||||
return ClassSession::query()
|
||||
@ -118,7 +118,7 @@ public function courses(): Collection
|
||||
}
|
||||
|
||||
$totalActiveStudents = Student::query()
|
||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
||||
->whereHas('user', fn ($q) => $q->active())
|
||||
->count();
|
||||
|
||||
return $query->get()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user