1. Go to this page and download the library: Download plutuss/static-text-laravel 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/ */
plutuss / static-text-laravel example snippets
use Plutuss\Models\Page;
use Plutuss\Http\Requests\StorePageRequest;
use Plutuss\Http\Requests\StorePageItemRequest;
class PageController extends Controller
{
public function index()
{
$page = Page::findByName('name_page');
return view('welcome', compact('page'))
}
public function addPage(StorePageRequest $request)
{
$page = Page::add(
name: 'home',
slug: '/',
template: 'main',
seo_title: 'seo_title', // this field can be empty
seo_description: 'seo_description' // this field can be empty
);
}
public function addPageItem(StorePageItemRequest $request)
{
$page = Page::findByName('home');
$pageItem = PageItem::add(
name: 'header',
page_id: $page->id,
data: [
[
'key' => 'h1',
'value' => 'Installed packages Laravel',
'type' => 'text',
],
[
'key' => 'image-bg',
'value' => 'path/image.jpg', // path image or file
'type' => 'image', // or file
]
]);
}
public function addPageItemWithLocale()
{
$pageItem = PageItem::add(
name: 'header',
page_id: $page->id,
data: [
[
'key' => 'h3_en', // You can specify a key with the available localisations in the application
'value' => 'Installed packages Laravel',
'type' => 'text',
],
[
'key' => 'h3_de', // You can specify a key with the available localisations in the application
'value' => 'Installierte Pakete Laravel',
'type' => 'text',
]
]);
}
}
<h1> {{ $page->show('header:h1') }} </h1>
// You can specify a default value
// if the ying a locale
<h3> {{ $page->show('header:h3') }} </h3>