LaravelPackages.net
Acme Inc.
Toggle sidebar
novius/laravel-nova-page-manager

A Laravel Nova package to manage pages.

10.825
0
6.4.7
About novius/laravel-nova-page-manager

novius/laravel-nova-page-manager is a Laravel package for a laravel nova package to manage pages.. It currently has 0 GitHub stars and 10.825 downloads on Packagist (latest version 6.4.7). Install it with composer require novius/laravel-nova-page-manager. Discover more Laravel packages by novius or browse all Laravel packages to compare alternatives.

Last updated

Laravel Nova Page Manager

This package allows you to manage pages with custom templates.

Requirements

  • PHP >= 8.2
  • Laravel >= 10.0
  • Laravel Nova >= 4.0

NOTE: These instructions are for Laravel >= 10.0 and PHP >= 8.2 If you are using prior version, please see the previous version's docs.

Installation

composer require novius/laravel-nova-page-manager

NOTE: These instructions are for Laravel Nova >= 4.0. If you are using prior version, please see the previous version's docs.

Validator translation

Please add this line to resource/lang/{locale}/validation.php (on first level) :

// EN version : resource/lang/en/validation.php
'unique_page' => 'The field :attribute must be unique in this language.',

// FR version : resource/lang/fr/validation.php
'unique_page' => 'Le champ :attribute doit être unique dans cette langue.',

Front Stuff

If you want a pre-generated front controller and route, you can run following command :

php artisan page-manager:publish-front

This command appends a route to routes/web.php and creates a new App\Http\Controllers\FrontPageController.

In Page templates use the documentation of laravel-meta to implement meta tags

Configuration

Some options that you can override are available.

php artisan vendor:publish --provider="Novius\LaravelNovaPageManager\LaravelNovaPageManagerServiceProvider" --tag="config"

Templates

To add a template, just add your custom class to templates array in configuration file.

Your class must extend Novius\LaravelNovaPageManager\Templates\AbstractPageTemplate.

Example :

In config/laravel-nova-page-manager.php

// ...

'templates' => [
    \App\Nova\Templates\StandardTemplate::class,
],

In app/Nova/Templates/StandardTemplate.php

<?php

namespace App\Nova\Templates;

use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\Trix;
use Novius\LaravelNovaPageManager\Templates\AbstractPageTemplate;

class StandardTemplate extends AbstractPageTemplate
{
    public function templateName(): string
    {
        return trans('laravel-nova-page-manager::template.standard_template');
    }

    public function templateUniqueKey(): string
    {
        return 'standard';
    }

    public function fields(): array
    {
        return [
            Trix::make('Content', 'content'),
            Date::make('Date', 'date'),
        ];
    }
    
    public function casts() : array
    {
        return [
            'date' => 'date',        
        ];
    }
}

Pour utiliser les champs spécifique du template :

$page = \Novius\LaravelNovaPageManager\Models\Page::where('template', 'standard')->first();

$content = $page->extras['content'];

// Date will be a Carbon instance, thanks to the cast
$date = $page->extras['date'];

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome!

Leave an issue on GitHub, or create a Pull Request.

Licence

This package is under GNU Affero General Public License v3 or (at your option) any later version.

Star History Chart