web/app/Models/Mall/MallCategory.php

64 lines
1.5 KiB
PHP

<?php
namespace App\Models\Mall;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @property int $id
* @property string $name
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Mall\MallItem> $items
* @property-read int|null $items_count
* @method static \Illuminate\Database\Eloquent\Builder<static>|MallCategory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|MallCategory newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|MallCategory query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|MallCategory whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|MallCategory whereName($value)
* @mixin \Eloquent
*/
class MallCategory extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
];
/**
* Get the items in this category
*/
public function items(): HasMany
{
return $this->hasMany(MallItem::class, 'category_id', 'id');
}
}