first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
<?php
namespace Modules\CCMS\Models;
use App\Traits\CreatedUpdatedBy;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Modules\CCMS\Traits\UpdateCustomFields;
// use Modules\CCMS\Database\Factories\PageFactory;
class Page extends Model
{
use HasFactory, UpdateCustomFields, CreatedUpdatedBy;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'section',
'template',
'type',
'description',
'short_description',
'image',
'images',
'banner',
'custom',
'link',
'sidebar_title',
'sidebar_content',
'sidebar_image',
'button_text',
'button_url',
'button_target',
'meta_title',
'meta_keywords',
'meta_description',
'date',
'status',
'order',
'created_by',
'updated_by',
];
protected function casts(): array
{
return [
'section' => 'array',
'custom' => 'array',
];
}
protected function images(): Attribute
{
return Attribute::make(
get: function ($value) {
if (empty($value)) {
return [];
}
$parts = explode(',', $value);
return array_map(fn($part) => asset(trim($part)), $parts);
}
);
}
protected function image(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
protected function banner(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
protected function sidebarImage(): Attribute
{
return Attribute::make(
get: fn($value) => asset($value),
);
}
public function children()
{
return $this->belongsToMany(
Page::class,
'page_relationship',
'parent_page_id',
'child_page_id',
'id',
'id'
);
}
public function parents()
{
return $this->belongsToMany(
Page::class,
'page_relationship',
'child_page_id',
'parent_page_id',
'id',
'id'
);
}
}