31 lines
722 B
PHP
31 lines
722 B
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use App\Models\AdSubcategory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
class Ads extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = 'ads';
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'pages' => 'array',
|
|
'subcategories' => 'array',
|
|
'unauthorized' => 'array',
|
|
'status' => 'boolean'
|
|
];
|
|
|
|
public function getSubcategoryNamesAttribute()
|
|
{
|
|
if (empty($this->subcategories)) {
|
|
return collect();
|
|
}
|
|
return AdSubcategory::whereIn('id', $this->subcategories) ->get() ->pluck('name');
|
|
}
|
|
}
|