first upload all files
This commit is contained in:
85
Modules/Page/Entities/Page.php
Normal file
85
Modules/Page/Entities/Page.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Page\Entities;
|
||||
|
||||
use Modules\Admin\Ui\AdminTable;
|
||||
use Modules\Support\Eloquent\Model;
|
||||
use Modules\Meta\Eloquent\HasMetaData;
|
||||
use Modules\Support\Eloquent\Sluggable;
|
||||
use Modules\Support\Eloquent\Translatable;
|
||||
|
||||
class Page extends Model
|
||||
{
|
||||
use Translatable, Sluggable, HasMetaData;
|
||||
|
||||
/**
|
||||
* The relations to eager load on every query.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $with = ['translations'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['slug', 'is_active'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are translatable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $translatedAttributes = ['name', 'body'];
|
||||
|
||||
/**
|
||||
* The attribute that will be slugged.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $slugAttribute = 'name';
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::addActiveGlobalScope();
|
||||
}
|
||||
|
||||
public static function urlForPage($id)
|
||||
{
|
||||
return static::select('slug')->firstOrNew(['id' => $id])->url();
|
||||
}
|
||||
|
||||
public function url()
|
||||
{
|
||||
if (is_null($this->slug)) {
|
||||
return '#';
|
||||
}
|
||||
|
||||
return localized_url(locale(), $this->slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table data for the resource
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
return new AdminTable($this->newQuery()->withoutGlobalScope('active'));
|
||||
}
|
||||
}
|
||||
15
Modules/Page/Entities/PageTranslation.php
Normal file
15
Modules/Page/Entities/PageTranslation.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Page\Entities;
|
||||
|
||||
use Modules\Support\Eloquent\TranslationModel;
|
||||
|
||||
class PageTranslation extends TranslationModel
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'body'];
|
||||
}
|
||||
Reference in New Issue
Block a user