change the migration columns and add form request

This commit is contained in:
2024-11-03 06:26:26 +00:00
parent e9098b0a55
commit 1a15a5d7ed
16 changed files with 444 additions and 66 deletions

View File

@@ -5,6 +5,7 @@ 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
{
@@ -12,8 +13,15 @@ class AzmayeshField extends Model
protected $guarded = [];
protected function option(): Attribute
{
return Attribute::make(
get: fn ($value) => json_decode($value),
);
}
public function azmayeshTypes(): BelongsToMany
{
return $this->belongsToMany(AzmayeshType::class);
return $this->belongsToMany(AzmayeshType::class, 'azmayesh_field_azmayesh_type');
}
}