PHP code example of postsimple / filament-postsimple
1. Go to this page and download the library: Download postsimple/filament-postsimple 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/ */
postsimple / filament-postsimple example snippets
use PostSimple\FilamentPostSimple\FilamentPostSimplePlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentPostSimplePlugin::make(),
]);
}
use PostSimple\FilamentPostSimple\Actions\SendToPostSimpleAction;
protected function getHeaderActions(): array
{
return [
SendToPostSimpleAction::make(),
// ... other actions
];
}
use PostSimple\FilamentPostSimple\Actions\SendToPostSimpleTableAction;
public static function table(Table $table): Table
{
return $table
->columns([
// ... your columns
])
->actions([
SendToPostSimpleTableAction::make(),
// ... other actions
]);
}
namespace App\Filament\Resources\PostResource\Pages;
use App\Filament\Resources\PostResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use PostSimple\FilamentPostSimple\Actions\SendToPostSimpleAction;
class EditPost extends EditRecord
{
protected static string $resource = PostResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
SendToPostSimpleAction::make(), // Add this line
];
}
}
// Works automatically - has 'title' field
class Post extends Model {
protected $fillable = ['title', 'content'];
}
// Works automatically - has 'name' field
class Product extends Model {
protected $fillable = ['name', 'price'];
}
// Needs customization - has different field
class Article extends Model {
protected $fillable = ['headline', 'body'];
}
// Use: ->titleAttribute('headline')
class Post extends Model
{
protected $fillable = ['title', 'slug', 'content'];
// Add this method to your model
public function getUrl(): string
{
return url('/blog/' . $this->slug);
}
}
class Product extends Model
{
public function getUrl(): string
{
return route('products.show', $this);
}
}