{ "error_code": "500", "data": { "zhuang_tai": "token_no", "times": "1764538817" } }
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Volume extends Model
{
protected $table = 'volumes';
protected $fillable = [
'name',
'size',
];
public function getSizeTitleAttribute() : string
{
return $this->size . ' ml';
}
public function getTitleAttribute() : string
{
return "$this->name - $this->size_title";
}
public function products() : BelongsToMany
{
return $this->belongsToMany(Product::class, 'product_volumes')
->withPivot('price')
->withTimestamps();
}
}