PHP code example of jordanpartridge / filament-skeleton
1. Go to this page and download the library: Download jordanpartridge/filament-skeleton 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/ */
jordanpartridge / filament-skeleton example snippets
use App\Models\Base\BaseModel;
class Post extends BaseModel
{
protected static function booted()
{
parent::booted();
static::registerModelPermissions();
}
}
// In controllers
if ($post->checkPermission(auth()->user(), 'update')) {
// Proceed with update
}
// In Blade templates
@can('update', $post)
<button>Edit Post</button>
@endcan
// In Filament resources
public static function canViewAny(): bool
{
return auth()->user()->can('view post');
}
class Post extends BaseModel
{
public static function getStandardPermissions(): array
{
return array_merge(parent::getStandardPermissions(), [
'publish',
'archive'
]);
}
}