When generating Laravel code, follow these strict patterns:
Migration Files:
Schema::create(\App\Models\Entities::Post->table(), function (Blueprint $table): void {
$table->id();
$table->string(\App\Models\Fields\PostFld::TITLE);
$table->timestamps();
});
Field Constants:
final class UserFld
{
use \App\Models\Traits\Fields\TimestampFlds;
public const NAME = 'name';
}
Model Structure:
/**
* @method static Builder|Post published()
*/
final class Post extends Model
{
use \App\Models\Getters\PostFldGttr;
public const AUTHOR_REL = 'author';
public function author(): BelongsTo
{
return $this->belongsTo(\App\Models\Author::class);
}
public function scopePublished(Builder $query): void
{
$query->where(\App\Models\Fields\PostFld::STATUS, \App\Enums\PostStatuses::Published);
}
}
Getter Traits:
/**
* @mixin \App\Models\Post
*/
trait PostFldGttr
{
use \App\Models\Traits\Getters\TimestampFldsGttr;
public function getTitle(): string
{
return $this->getAttribute(\App\Models\Fields\PostFld::TITLE);
}
}
Filament Resource Structure:
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Actions\BulkActionGroup;
use Filament\Tables\Actions\DeleteBulkAction;
use Filament\Tables\Table;
use Filament\Forms\Form;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
final class PostResource extends \App\Support\Filament\Resource\Resource
{
public static function table(Table $table): Table
{
return $table
->columns(self::tableSchema())
->filters(self::tableFilters())
->actions([
EditAction::make()
])
->bulkActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
public static function tableSchema(): array
{
return [
TextColumn::make(PostFld::TITLE)
->label('عنوان')
->searchable(),
...self::addTimestamps()
];
}
public static function tableFilters(): array
{
return [
...self::datetimeRangeFilter(),
];
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make(PostFld::TITLE)
->label('عنوان')
->maxLength(255)
->required(),
]);
}
Requirements:
Always use field constants from \App\Models\Fields\ classes
Include proper PHPDoc annotations for scopes and mixins
Use final classes for models and resources
Include proper return types for all methods
Use relationship constants (e.g., AUTHOR_REL) for relationship names
Generate corresponding Filament resources when creating models
Use proper MySQL column types in migrations
Include timestamps in migrations unless specified otherwise
Follow Persian labels in Filament forms/tables when appropriate