Kaesa Lyrih
Kaesa Lyrih
FFilament
Created by TheAbhishekIN on 4/15/2024 in #❓┊help
is there any filament feature or plugin available for mention users ?
8 replies
FFilament
Created by IWBW on 5/30/2024 in #❓┊help
Profile view and profile edit
13 replies
FFilament
Created by IWBW on 5/30/2024 in #❓┊help
Profile view and profile edit
Try to custom page ->profile(page: CustomPageViewProfile::class)
13 replies
FFilament
Created by arif on 5/28/2024 in #❓┊help
Displaying data without an ID or primary key
Try add:
// ...
protected $primaryKey = 'NIK';
public $incrementing = false;
protected $keyType = 'string';
// ...
// ...
protected $primaryKey = 'NIK';
public $incrementing = false;
protected $keyType = 'string';
// ...
3 replies
FFilament
Created by Kaesa Lyrih on 5/19/2024 in #❓┊help
Can Query Model Pivot Custom Table without field id?
- Custom Table Livewire ListStudentEnrollments
<?php

// ...

class ListStudentEnrollments extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

public function table(Table $table): Table
{
return $table
->query(Enrollment::query())
->columns([
Tables\Columns\TextColumn::make('classroom.name')
->sortable(),
Tables\Columns\TextColumn::make('classroom.end_date')
->dateTime()
->sortable(),
])
->filters([
//
])
->actions([
//
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
//
]),
]);
}

public function render(): View
{
return view('livewire.guardian.list-student-enrollments');
}
}
<?php

// ...

class ListStudentEnrollments extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;

public function table(Table $table): Table
{
return $table
->query(Enrollment::query())
->columns([
Tables\Columns\TextColumn::make('classroom.name')
->sortable(),
Tables\Columns\TextColumn::make('classroom.end_date')
->dateTime()
->sortable(),
])
->filters([
//
])
->actions([
//
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
//
]),
]);
}

public function render(): View
{
return view('livewire.guardian.list-student-enrollments');
}
}
5 replies
FFilament
Created by Kaesa Lyrih on 5/19/2024 in #❓┊help
Can Query Model Pivot Custom Table without field id?
- Pivot Model Enrollment
protected $table = 'enrollments';
protected $foreignKey = 'classroom_id';
protected $relatedKey = 'student_id';
public $incrementing = false;

public function classroom(): BelongsTo
{
return $this->belongsTo(Classroom::class);
}

public function student(): BelongsTo
{
return $this->belongsTo(Student::class);
}
protected $table = 'enrollments';
protected $foreignKey = 'classroom_id';
protected $relatedKey = 'student_id';
public $incrementing = false;

public function classroom(): BelongsTo
{
return $this->belongsTo(Classroom::class);
}

public function student(): BelongsTo
{
return $this->belongsTo(Student::class);
}
5 replies
FFilament
Created by Kaesa Lyrih on 5/19/2024 in #❓┊help
Can Query Model Pivot Custom Table without field id?
- Table enrollments
Schema::create('enrollments', function (Blueprint $table) {
$table->unsignedBiginteger('classroom_id')->unsigned();
$table->unsignedBiginteger('student_id')->unsigned();
$table->foreign('classroom_id')->on('classrooms')->references('id')->onDelete('cascade');
$table->foreign('student_id')->on('students')->references('id')->onDelete('cascade');
$table->primary(['classroom_id', 'student_id']);
$table->timestamps();
});
Schema::create('enrollments', function (Blueprint $table) {
$table->unsignedBiginteger('classroom_id')->unsigned();
$table->unsignedBiginteger('student_id')->unsigned();
$table->foreign('classroom_id')->on('classrooms')->references('id')->onDelete('cascade');
$table->foreign('student_id')->on('students')->references('id')->onDelete('cascade');
$table->primary(['classroom_id', 'student_id']);
$table->timestamps();
});
5 replies
FFilament
Created by Kaesa Lyrih on 5/7/2024 in #❓┊help
how to get data in action child from action parent?
My study case, solve with action chanining. https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#chaining-actions
class ManageFinancialTransactions extends ManageRecords
{
protected static string $resource = FinancialTransactionResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('generate_report_pdf')
->model(FinancialTransaction::class)
->form([
Select::make('wallet_id'),
DatePicker::make('start_transaction_at'),
DatePicker::make('end_transaction_at'),
])
->action(function (array $data) {
$this->replaceMountedAction('viewPdf',arguments: $data);
})
];
}

public function viewPdfAction(): Action
{
return Action::make('name_action')
->modal()
->modalContent(
function ($record, $livewire, $action, $arguments, $data) {
dd([$record, $livewire, $action, $arguments, $data]);
$object = view('components.object-pdf', [
'src' => route('admin.financial-transactions.pdf', [
'filter' => $arguments
])
]);
return $object;
}
)
->slideOver()
->modalSubmitAction(false)
->modalCancelAction(false);
}
}
class ManageFinancialTransactions extends ManageRecords
{
protected static string $resource = FinancialTransactionResource::class;

protected function getHeaderActions(): array
{
return [
Action::make('generate_report_pdf')
->model(FinancialTransaction::class)
->form([
Select::make('wallet_id'),
DatePicker::make('start_transaction_at'),
DatePicker::make('end_transaction_at'),
])
->action(function (array $data) {
$this->replaceMountedAction('viewPdf',arguments: $data);
})
];
}

public function viewPdfAction(): Action
{
return Action::make('name_action')
->modal()
->modalContent(
function ($record, $livewire, $action, $arguments, $data) {
dd([$record, $livewire, $action, $arguments, $data]);
$object = view('components.object-pdf', [
'src' => route('admin.financial-transactions.pdf', [
'filter' => $arguments
])
]);
return $object;
}
)
->slideOver()
->modalSubmitAction(false)
->modalCancelAction(false);
}
}
6 replies
FFilament
Created by Kaesa Lyrih on 5/7/2024 in #❓┊help
how to get data in action child from action parent?
problem, validated form data not work in extraModalFooterActions, humm.
6 replies
FFilament
Created by Kaesa Lyrih on 5/7/2024 in #❓┊help
how to get data in action child from action parent?
I temp solve using $livewire->mountedActionsData[0] to get data action perent, any other solution?
Action::make('child_action')
->modal()
->modalContent(function ($record, $livewire) use ($action, $arguments, $data) {
dd([
$data,
$record,
$livewire->mountedActionsData[0],
$arguments,
$action
]);
$object = '...';
return str($object)->toHtmlString();
}),
Action::make('child_action')
->modal()
->modalContent(function ($record, $livewire) use ($action, $arguments, $data) {
dd([
$data,
$record,
$livewire->mountedActionsData[0],
$arguments,
$action
]);
$object = '...';
return str($object)->toHtmlString();
}),
6 replies
FFilament
Created by Kaesa Lyrih on 5/7/2024 in #❓┊help
how to get data in action child from action parent?
dd([$data, $record, $livewire, $arguments, $action]);
// result:
// $data = [],
// $record = null,
// $livewire = ManageTransaciton::class
// $arguments = [],
// $action = Action::class
dd([$data, $record, $livewire, $arguments, $action]);
// result:
// $data = [],
// $record = null,
// $livewire = ManageTransaciton::class
// $arguments = [],
// $action = Action::class
How to get data form Action parent_action to child Action child_action modalContent()?
6 replies
FFilament
Created by Kaesa Lyrih on 12/11/2023 in #❓┊help
filter table column relation
Done solve https://github.com/filamentphp/filament/discussions/9067#discussioncomment-7271187
Tables\Filters\SelectFilter::make('current_school')
->label('Sekolah')
->options([
'PAUD' => 'PAUD',
'TK' => 'TK',
'SD' => 'SD',
'SMP' => 'SMP',
'SMK' => 'SMK',
])->modifyQueryUsing(
function (Builder $query, $data) {
if (!$data['values']) {
return $query;
}
return $query->whereHas('student', function (Builder $query) use ($data) {
return $query->whereIn('current_school', $data['values']);
});
}
)
->multiple(),
Tables\Filters\SelectFilter::make('current_school')
->label('Sekolah')
->options([
'PAUD' => 'PAUD',
'TK' => 'TK',
'SD' => 'SD',
'SMP' => 'SMP',
'SMK' => 'SMK',
])->modifyQueryUsing(
function (Builder $query, $data) {
if (!$data['values']) {
return $query;
}
return $query->whereHas('student', function (Builder $query) use ($data) {
return $query->whereIn('current_school', $data['values']);
});
}
)
->multiple(),
4 replies
FFilament
Created by Kaesa Lyrih on 11/14/2023 in #❓┊help
Summarize Table RelationManager
Code: - Pivot table: create_package_product_table.php
public function up(): void
{
Schema::create('package_product', function (Blueprint $table) {
$table->id();
$table->foreignId('package_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
public function up(): void
{
Schema::create('package_product', function (Blueprint $table) {
$table->id();
$table->foreignId('package_id')->constrained()->cascadeOnDelete();
$table->foreignId('product_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
- Model Package.php
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class, 'package_product')->withPivot('id')->withTimestamps();
}
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class, 'package_product')->withPivot('id')->withTimestamps();
}
- Model Product.php
public function packages(): BelongsToMany
{
return $this->belongsToMany(Package::class, 'package_product')->withPivot('id')->withTimestamps();
}
public function packages(): BelongsToMany
{
return $this->belongsToMany(Package::class, 'package_product')->withPivot('id')->withTimestamps();
}
- ProductResource.php
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('price')->summarize(Sum::make()),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('price')->summarize(Sum::make()),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
- ProductRelationManager.php in PackageResource.php
public function table(Table $table): Table
{
return ProductResource::table($table)
->headerActions([
Tables\Actions\AttachAction::make()->preloadRecordSelect(),
])
->actions([
Tables\Actions\DetachAction::make(),
])
->groupedBulkActions([
Tables\Actions\DetachBulkAction::make(),
]);
}
public function table(Table $table): Table
{
return ProductResource::table($table)
->headerActions([
Tables\Actions\AttachAction::make()->preloadRecordSelect(),
])
->actions([
Tables\Actions\DetachAction::make(),
])
->groupedBulkActions([
Tables\Actions\DetachBulkAction::make(),
]);
}
5 replies