123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Repositories\Models\CMS;
- use App\Repositories\Models\Base\Admin;
- use App\Repositories\Models\Base\Resource;
- use App\Repositories\Models\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Article.
- *
- * @package namespace App\Repositories\Models\CMS;
- */
- class Article extends Model implements Transformable
- {
- use TransformableTrait;
- protected $table = 'cms_articles';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $guarded = [];
- protected static function booted()
- {
- self::language();
- }
- public function cover_resource()
- {
- return $this->belongsTo(Resource::class, 'cover', 'id')->select(['path', 'id', 'url']);
- }
- public function setTagsAttribute($val)
- {
- $this->attributes['tags'] = '-' . arr2str($val, '-') . '-';
- }
- public function getTagsAttribute($val)
- {
- return str2arr(trim($val, '-'), '-');
- }
- public function category()
- {
- return $this->belongsTo(Category::class);
- }
- public function admin()
- {
- return $this->belongsTo(Admin::class);
- }
- }
|