58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $group_id
|
|
* @property string $key
|
|
* @property string $name
|
|
* @property string $intro
|
|
* @property Collection $configs
|
|
* @property Carbon $updated_at
|
|
* @property Carbon $created_at
|
|
* @property-read Group $group
|
|
* @property-read Image[] $images
|
|
*/
|
|
class Strategy extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'group_id',
|
|
'key',
|
|
'name',
|
|
'intro',
|
|
'configs',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'group_id',
|
|
];
|
|
|
|
protected $attributes = [
|
|
'intro' => '',
|
|
];
|
|
|
|
protected $casts = [
|
|
'configs' => 'collection',
|
|
];
|
|
|
|
public function group(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Group::class, 'group_id', 'id');
|
|
}
|
|
|
|
public function images(): HasMany
|
|
{
|
|
return $this->hasMany(Image::class, 'strategy_id', 'id');
|
|
}
|
|
}
|