Vhelkhana
How do I make the minDate be the value of another field?
Thanks! This worked for me:
DatePicker::make('date_requested')
->maxDate(now())
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$set('date_of_payment', $state);
$set('expected_release', $state);
$set('date_received', $state);
}),
DatePicker::make('date_of_payment')
->minDate(fn (callable $get) => $get('date_requested'))
->required(),
DatePicker::make('expected_release')
->minDate(fn (callable $get) => $get('date_requested'))
->required(),
DatePicker::make('date_received')
->minDate(fn (callable $get) => $get('date_requested')),
DatePicker::make('date_requested')
->maxDate(now())
->required()
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$set('date_of_payment', $state);
$set('expected_release', $state);
$set('date_received', $state);
}),
DatePicker::make('date_of_payment')
->minDate(fn (callable $get) => $get('date_requested'))
->required(),
DatePicker::make('expected_release')
->minDate(fn (callable $get) => $get('date_requested'))
->required(),
DatePicker::make('date_received')
->minDate(fn (callable $get) => $get('date_requested')),
5 replies
Filament with Livewire, sort and search not working
Livewire file:
<?php
namespace App\Livewire;
use App\Mail\StudentPortalCredentials;
use App\Models\PendingEmailStudentPortal;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\BulkAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use Livewire\Component;
class ListPendingEmailStudentPortal extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
protected $listeners = ['emailAll' => 'emailAll'];
public function render()
{
return view('livewire.list-pending-email-student-portal');
}
public function table(Table $table): Table
{
return $table
->query(PendingEmailStudentPortal::with('student'))
->columns([
TextColumn::make('student.student_no')
->label('Student Number')
->sortable(),
TextColumn::make('student.last_name')
->label('Last Name'),
TextColumn::make('student.first_name')
->label('First Name'),
TextColumn::make('student.middle_name')
->label('Middle Name'),
TextColumn::make('student.personal_email')
->label('Personal Email'),
TextColumn::make('Status')
->default('Pending'),
])
->defaultSort('student.student_no', 'asc')
->paginated(false);
}
public function handleClick()
{
$this->dispatchBrowserEvent('emailAll');
}
<?php
namespace App\Livewire;
use App\Mail\StudentPortalCredentials;
use App\Models\PendingEmailStudentPortal;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\BulkAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;
use Livewire\Component;
class ListPendingEmailStudentPortal extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
protected $listeners = ['emailAll' => 'emailAll'];
public function render()
{
return view('livewire.list-pending-email-student-portal');
}
public function table(Table $table): Table
{
return $table
->query(PendingEmailStudentPortal::with('student'))
->columns([
TextColumn::make('student.student_no')
->label('Student Number')
->sortable(),
TextColumn::make('student.last_name')
->label('Last Name'),
TextColumn::make('student.first_name')
->label('First Name'),
TextColumn::make('student.middle_name')
->label('Middle Name'),
TextColumn::make('student.personal_email')
->label('Personal Email'),
TextColumn::make('Status')
->default('Pending'),
])
->defaultSort('student.student_no', 'asc')
->paginated(false);
}
public function handleClick()
{
$this->dispatchBrowserEvent('emailAll');
}
3 replies
->sortable(), searchable(), and pagination not working with Livewire
resources/views/credential-generation-dashboard.blade.php:
@filamentStyles
<div wire:init="$refresh">
<x-app-layout>
<!-- Header -->
<x-header title="Credential Generation" />
<div x-data="{ activeTab: 'student-portal-account' }">
<x-tab-navigation tab1Title="Student Portal Account" tab2Title="PLM Email" />
<!-- Tab Contents -->
<div x-show="activeTab === 'student-portal-account'">
<section class="p-4 rounded-lg" role="tabpanel" aria-labelledby="student-portal-account-tab">
<!-- Buttons Container -->
<div class="flex items-center justify-between mb-4">
<x-email-all-button student-count="2000" button-text="Email all" />
<x-edit-email-template-button modal-id="sp-account-modal"
modal-title="Student Portal Account Email Template" />
</div>
<!-- Pending Credentials Table -->
<livewire:list-pending-email-student-portal />
</section>
</div>
<div x-show="activeTab === 'plm-email'">
<section class="p-4 rounded-lg" role="tabpanel" aria-labelledby="plm-email-tab">
<!-- Buttons Container -->
<div class="flex items-center justify-between mb-4">
<x-email-all-button student-count="2000" button-text="Email all" />
<x-edit-email-template-button modal-id="plm-email-modal"
modal-title="PLM Email Credentials Email Template" />
</div>
<!-- Pending Credentials Table -->
<livewire:list-pending-email-p-l-m-email />
</section>
</div>
</div>
</x-app-layout>
</div>
@filamentStyles
<div wire:init="$refresh">
<x-app-layout>
<!-- Header -->
<x-header title="Credential Generation" />
<div x-data="{ activeTab: 'student-portal-account' }">
<x-tab-navigation tab1Title="Student Portal Account" tab2Title="PLM Email" />
<!-- Tab Contents -->
<div x-show="activeTab === 'student-portal-account'">
<section class="p-4 rounded-lg" role="tabpanel" aria-labelledby="student-portal-account-tab">
<!-- Buttons Container -->
<div class="flex items-center justify-between mb-4">
<x-email-all-button student-count="2000" button-text="Email all" />
<x-edit-email-template-button modal-id="sp-account-modal"
modal-title="Student Portal Account Email Template" />
</div>
<!-- Pending Credentials Table -->
<livewire:list-pending-email-student-portal />
</section>
</div>
<div x-show="activeTab === 'plm-email'">
<section class="p-4 rounded-lg" role="tabpanel" aria-labelledby="plm-email-tab">
<!-- Buttons Container -->
<div class="flex items-center justify-between mb-4">
<x-email-all-button student-count="2000" button-text="Email all" />
<x-edit-email-template-button modal-id="plm-email-modal"
modal-title="PLM Email Credentials Email Template" />
</div>
<!-- Pending Credentials Table -->
<livewire:list-pending-email-p-l-m-email />
</section>
</div>
</div>
</x-app-layout>
</div>
4 replies
->sortable(), searchable(), and pagination not working with Livewire
app/Livewire/ListPendingEmailStudentPortal.php:
<?php
namespace App\Livewire;
use Livewire\Component;
use App\Models\PendingEmailStudentPortal;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Builder;
class ListPendingEmailStudentPortal extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
public function render()
{
return view('livewire.list-pending-email-student-portal');
}
public function table(Table $table): Table
{
return $table
->query(PendingEmailStudentPortal::with('student'))
->columns([
TextColumn::make('student.student_no')
->label('Student Number')
->sortable(),
TextColumn::make('student.last_name')
->label('Last Name'),
TextColumn::make('student.first_name')
->label('First Name'),
TextColumn::make('student.middle_name')
->label('Middle Name'),
TextColumn::make('student.personal_email')
->label('Personal Email'),
TextColumn::make('Status')
->default('Pending'),
])
->defaultSort('student.student_no', 'asc');
}
}
<?php
namespace App\Livewire;
use Livewire\Component;
use App\Models\PendingEmailStudentPortal;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Builder;
class ListPendingEmailStudentPortal extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
public function render()
{
return view('livewire.list-pending-email-student-portal');
}
public function table(Table $table): Table
{
return $table
->query(PendingEmailStudentPortal::with('student'))
->columns([
TextColumn::make('student.student_no')
->label('Student Number')
->sortable(),
TextColumn::make('student.last_name')
->label('Last Name'),
TextColumn::make('student.first_name')
->label('First Name'),
TextColumn::make('student.middle_name')
->label('Middle Name'),
TextColumn::make('student.personal_email')
->label('Personal Email'),
TextColumn::make('Status')
->default('Pending'),
])
->defaultSort('student.student_no', 'asc');
}
}
4 replies
Column relationships dot syntax not working
Student model:
class Student extends Model
{
use HasFactory;
protected $guarded = [
'id',
'created_at',
'updated_at',
];
public function degreeProgram(): BelongsTo
{
return $this->belongsTo(DegreeProgram::class);
}
public function birthplaceCity(): BelongsTo
{
return $this->belongsTo(City::class, 'birthplace_city_id');
}
public function city(): BelongsTo
{
return $this->belongsTo(City::class);
}
public function biologicalSex(): BelongsTo
{
return $this->belongsTo(BiologicalSex::class);
}
public function civilStatus(): BelongsTo
{
return $this->belongsTo(CivilStatus::class);
}
public function registrationStatus(): BelongsTo
{
return $this->belongsTo(RegistrationStatus::class);
}
public function studentFamily(): HasOne
{
return $this->hasOne(StudentFamily::class);
}
public function assignedClasses(): HasMany
{
return $this->hasMany(AssignedClass::class);
}
public function studentRecords(): HasMany
{
return $this->hasMany(StudentRecord::class);
}
public function studentViolations(): HasMany
{
return $this->hasMany(StudentViolation::class);
}
public function studentRequests(): HasMany
{
return $this->hasMany(StudentRequest::class);
}
public function academicYear(): BelongsTo
{
return $this->belongsTo(AcademicYear::class);
}
}
class Student extends Model
{
use HasFactory;
protected $guarded = [
'id',
'created_at',
'updated_at',
];
public function degreeProgram(): BelongsTo
{
return $this->belongsTo(DegreeProgram::class);
}
public function birthplaceCity(): BelongsTo
{
return $this->belongsTo(City::class, 'birthplace_city_id');
}
public function city(): BelongsTo
{
return $this->belongsTo(City::class);
}
public function biologicalSex(): BelongsTo
{
return $this->belongsTo(BiologicalSex::class);
}
public function civilStatus(): BelongsTo
{
return $this->belongsTo(CivilStatus::class);
}
public function registrationStatus(): BelongsTo
{
return $this->belongsTo(RegistrationStatus::class);
}
public function studentFamily(): HasOne
{
return $this->hasOne(StudentFamily::class);
}
public function assignedClasses(): HasMany
{
return $this->hasMany(AssignedClass::class);
}
public function studentRecords(): HasMany
{
return $this->hasMany(StudentRecord::class);
}
public function studentViolations(): HasMany
{
return $this->hasMany(StudentViolation::class);
}
public function studentRequests(): HasMany
{
return $this->hasMany(StudentRequest::class);
}
public function academicYear(): BelongsTo
{
return $this->belongsTo(AcademicYear::class);
}
}
6 replies