A package to easily add meta for crud models and forms to your page.
The package can be installed via composer and will autoregister.
composer require litstack/meta
You can now publish and migrate the migration for your meta model:
php artisan vendor:publish --provider="Litstack\Meta\MetaServiceProvider" --tag=migrations
php artisan migrate
Start by preparing your Model by using the HasMeta
Trait and implement the
metaable
Contract:
use Litstack\Meta\Metaable;
use Litstack\Meta\Traits\HasMeta;
class Post extends Model implements Metaable
{
use HasMeta;
}
Forms don't need further setup
In order to display the form in litstack edit your model-config:
use Litstack\Meta\Traits\CrudHasMeta;
class PostConfig extends CrudConfig
{
use CrudHasMeta;
// …
public function show(CrudShow $page)
{
$this->meta($page);
}
}
You may disable certain fields in the meta modal:
$this->meta($page, disable: [
'description',
'keywords'
]);
To display the meta-fields in your template, simply use the <x-lit-meta />
component and pass it the metaFields
of your model.
<head>
...
<x-lit-meta :for="$post" />
...
</head>