Pages

Pages

Pages & Model's Pages.

Moamen Eltouny (Raggi)
PHP Version : >= 7.2 Laravel Version : >= 6.0 License Support
Source Packagist Version Packagist Downloads

Install

Install the latest version using Composer

composer require pharaonic/laravel-pages

Depends on : Translatable, Sluggable

Creating

Create a new page.

$page = Page::create(['published' => true]);

$page->translateOrNew('en')->title = 'title here';
$page->translateOrNew('en')->content = 'content here';
$page->translateOrNew('en')->description = 'description here';
$page->translateOrNew('en')->keywords = 'word1,word2,word3';
$page->save();
Retrieving

Create a new page.

$page = Page::find(1);
$page = page(1); // OR

$title = $page->translate('en')->title;
$slug  = $page->translate('en')->slug;
...
Has-Pages

HasPages inclusion in your model.

You can ignore using $pagesAttributes variable [ Default: page ].

use Pharaonic\Laravel\Pages\HasPages;
...

class Company extends Model
{
    use HasPages;
    ...

    /**
     * Pages attribute's name
     *
     * @var array
     */
    protected $pagesAttributes = ['terms', 'privacy'];
}

Attach the page with the model

$company = Company::find(1);
$page = page(1);

$company->terms = $page;

Relationships

dump($company->pages);