added casts to plan model

This commit is contained in:
2023-12-06 13:43:55 +03:00
parent 1f958bb971
commit 0a10264850

View File

@@ -12,13 +12,22 @@ use CyrildeWit\EloquentViewable\Contracts\Viewable;
class Plan extends Model implements Viewable
{
use HasFactory, InteractsWithViews;
use HasFactory;
use InteractsWithViews;
protected $withCount = [
'likes',
'comments'
];
protected $casts = [
'type' => 'array',
'packet1_options' => 'array',
'packet2_options' => 'array',
'packet3_options' => 'array',
];
public function author()
{
return $this->belongsToMany(User::class, 'plan_author', 'plan_id', 'user_id');
@@ -62,7 +71,7 @@ class Plan extends Model implements Viewable
$data = $this->unserializeOptionsArr($this->type);
return new Attribute(
get: fn() => array_keys($data),
get: fn () => array_keys($data),
);
}
@@ -79,7 +88,7 @@ class Plan extends Model implements Viewable
}
return new Attribute(
get: fn() => $result,
get: fn () => $result,
);
}