123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace App\Repositories\Models\TCM;
- use App\Repositories\Models\Model;
- use Prettus\Repository\Contracts\Transformable;
- use Prettus\Repository\Traits\TransformableTrait;
- /**
- * Class Category.
- *
- * @package namespace App\Repositories\Models\TCM;
- */
- class Category extends Model implements Transformable
- {
- use TransformableTrait;
- protected $table = 'tcm_categories';
- /**
- * The attributes that are mass assignable.
- *
- * @var array
- */
- protected $guarded = [];
- protected static function booted()
- {
- self::language();
- }
- public static function byIdGetCategoryValue($id)
- {
- return self::query()->where('id', $id)->value('title');
- }
- public static function byIdsGetCategoryValue($ids)
- {
- return self::query()->whereIn('id', $ids)->pluck('title')->toArray();
- }
- public function getParentNameAttribute()
- {
- return self::query()->where('id', $this->attributes['parent_id'])->value('title') ?? '--';
- }
- }
|