forked from eatvio/eatvio-infra
added casts to plan model
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user