<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codewithdennis / filament-factory-action example snippets
class ProfileFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->company(),
'is_public' => rand(0, 1),
];
}
}
FactoryAction::make(),
use App\Filament\Resources\ProfileResource;
use CodeWithDennis\FactoryAction\FactoryAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListProfiles extends ListRecords
{
protected static string $resource = ProfileResource::class;
protected function getHeaderActions(): array
{
return [
FactoryAction::make()
->color('danger')
// ->slideOver()
->icon('heroicon-o-wrench'),
Actions\CreateAction::make()
];
}
}
protected function getHeaderActions(): array
{
return [
FactoryAction::make()
// If you want to create or create and attach you can do so using `hasMany`
->hasMany([Badge::class, Category::class])
// If you want to attach existing models you can do so using `belongsToMany`
->belongsToMany([Badge::class, Category::class]),
];
}
->hidden(fn() => false)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.