****# Clean Laravel CMS Laravel CMS Clean
|-- routes
| |-- admin.php - this is admin routing file
| |-- web.php - this is client routing file
In your .php file, in the render() method, at the end of the line return view(); add layout('components.layouts.admin.authorized');
In your migration file insert this example, this util class, economy you time from create translatable model and migration class for multi language
\App\Utils\WithTranslatable::create($modelClass, $foreignId, $mappedFillable, $modelPrimaryId);$modelClass = \App\Models\Page::class;$mappedFillable = [
['string' => 'title'],
['string' => 'name'],
['mediumText' => 'description'],
['mediumText' => 'keywords'],
['longText' => 'body'],
];In your livewire component include this snippet
<livewire:admin.components.tree.tree-inner :model-class="get_class($itemsCollection[0]->getModel())" :elements="$itemsCollection" />use App\Traits\WithTree;
protected $childModel = YouChildModel::class;
protected $childForeignId = 'foreign_id';
protected $routeNames = [
'edit' => 'admin.pages.edit',
'create' => 'admin.pages.create',
];
protected $showEditLink = true;
protected $showCreateLink = true;| $childModel | string | This variable of child element model |
| $childForeignId: string | string | This variable of child model, where foreign id for parent table in DB |
| $routNames | array | In this variable write you edit and create link |
| $showEditLink | bool | This variable toggle show 'edit' link in your tree view item. Default: true |
| $showCreateLink | bool | This variable toggle show 'create' link in your tree view item. Default: true |
In you component use this example
<textarea name="content" data-is-upload="true" id="content" data-tiny data-tinymce-id="content" cols="30" rows="10"></textarea>| data-tiny | this data attribute required from instance editor. |
| data-is-upload | true or false, from show file manager uploader |
| data-tinymce-id | attribute id. |
<script>
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
adminFunctions.tinymceInstances()['content'].on('change', () => {
@this.set('model', adminFunctions.tinymceInstances()['content'].getContent())
})
}, 200);
});
</script>Create two model, own model and nameTranslation
Create own model and add this example code
$translationFkName - Foreign key in table with translates
$translationTableName - Translatable model name
$translationModelClass - Translatable model class
is const TABLE_NAME - current table name
use Translatable;
protected string $translationFkName = 'page_id';
protected string $translationTableName = PageTranslation::TABLE_NAME;
protected string $translationModelClass = PageTranslation::class;
public const TABLE_NAME = "page";
protected $table = self::TABLE_NAME;Create translatable model and add this code
is const TABLE_NAME - Current table name;
public const TABLE_NAME = "page_translation";
protected $table = self::TABLE_NAME;From use SEO add
use SeoTrait;title - this is title from <title></title>
description - this is title from <meta name="description"
keywords - this is title from <meta name="keywords"
ogg_title - this is Social preview title from <meta property="og:title" and another social title meta tags
ogg_description - this is og:description from <meta property="og:description" and another social descriptions meta tags
image_url - this is og:image from <meta property="og:image" and another social image(preview) meta tags
ogg_image - this is og:image from <meta property="og:image" and another social image(preview) meta tags
In your .php class of livewire component add given code
Inside the body of the class
public string|null $temp_id = null;In mount() method paste this code
if(!$this->isEditMode)
$this->temp_id = uniqid();In your .blade livewire component paste this code
@if($isEditMode)
<livewire:admin.components.gallery :model-type="\App\Models\Page::class" is-edit="1" :model-id="$item->id"/>
@else
<livewire:admin.components.gallery :model-type="\App\Models\Page::class"/>
@endifmodel-type - Insert your model class with namespace(in editing record it required property)
model-id - Is record id example :model-id="$item->id"
model-type - Insert your model class with namespace(in editing record it required property)
if editing mode the is-edit required property and pass in 1
In your save method, after model->save(); paste this code
$this->item->id replace for your public property
if(!$this->isEditMode){
$galleryItems = \App\Models\Gallery::findByModelTypeAndTempId(\App\Models\Page::class, $this->temp_id);
foreach($galleryItems as $image) {
$image->model_id = $this->item->id;
$image->temp_id = null;
$image->save();
}
}Run command
$ php artisan role:installRun command
$ php artisan role:uninstallTELEGRAM_BOT_ACCESS_TOKEN=#Put her telegram bot token
TELEGRAM_CHAT_ID=#Put her chat id