feat: tambah penanggung jawab divisi (leader_id) dari role pengurus
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\Divisions\Schemas;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -13,6 +15,12 @@ class DivisionForm
|
||||
return $schema->components([
|
||||
TextInput::make('name')->label('Nama')->required(),
|
||||
Textarea::make('description')->label('Deskripsi')->rows(3)->columnSpanFull(),
|
||||
Select::make('leader_id')->label('Penanggung Jawab')
|
||||
->options(
|
||||
User::role('pengurus')->where('status', 'aktif')->pluck('name', 'id')
|
||||
)
|
||||
->searchable()
|
||||
->nullable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class DivisionsTable
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Nama')->searchable()->sortable(),
|
||||
TextColumn::make('description')->label('Deskripsi')->limit(50),
|
||||
TextColumn::make('leader.name')->label('Penanggung Jawab')->default('-'),
|
||||
TextColumn::make('members_count')->counts('members')->label('Anggota'),
|
||||
])
|
||||
->recordActions([EditAction::make()])
|
||||
|
||||
@@ -7,10 +7,15 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Division extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'description'];
|
||||
protected $fillable = ['name', 'description', 'leader_id'];
|
||||
|
||||
public function members(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function leader(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'leader_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user