29 lines
663 B
PHP
29 lines
663 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
class AzmayeshField extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
protected $hidden = ['pivot'];
|
|
|
|
protected function option(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn ($value) => json_decode($value),
|
|
);
|
|
}
|
|
|
|
public function azmayeshTypes(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(AzmayeshType::class, 'azmayesh_field_azmayesh_type');
|
|
}
|
|
}
|