PHP code example of peltonsolutions / filament-common

1. Go to this page and download the library: Download peltonsolutions/filament-common library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

peltonsolutions / filament-common example snippets


use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\CreatedAtColumn;
use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\UpdatedAtColumn;
use PeltonSolutions\FilamentCommon\Filament\Tables\Columns\DeletedAtColumn;

// In your Filament resource's table() method:
CreatedAtColumn::make(),
UpdatedAtColumn::make(),
DeletedAtColumn::make(),

use PeltonSolutions\FilamentCommon\Filament\Forms\Components\CreatedAtView;
use PeltonSolutions\FilamentCommon\Filament\Forms\Components\UpdatedAtView;

// In your Filament resource's form() method:
CreatedAtView::make(),
UpdatedAtView::make(),

use PeltonSolutions\FilamentCommon\Filament\Forms\Components\LinkedFieldView;

class UserFieldView extends LinkedFieldView
{
    protected function getRelatedRecord(int|string|null $id): ?Model
    {
        return User::find($id);
    }

    protected function displayName(Model $relatedRecord): string
    {
        return $relatedRecord->name;
    }

    protected function getRelatedRecordURL(int|string|null $id): ?string
    {
        return UserResource::getUrl('view', ['record' => $id]);
    }
}