24 lines
558 B
PHP
24 lines
558 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
|
||
|
|
class HomeSection extends Model
|
||
|
|
{
|
||
|
|
protected $fillable = ['title', 'slug', 'sort', 'display_limit', 'status'];
|
||
|
|
|
||
|
|
protected function casts(): array
|
||
|
|
{
|
||
|
|
return ['sort' => 'integer', 'display_limit' => 'integer'];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function tools(): BelongsToMany
|
||
|
|
{
|
||
|
|
return $this->belongsToMany(Tool::class, 'home_section_tool')
|
||
|
|
->withPivot('sort')
|
||
|
|
->orderByPivot('sort');
|
||
|
|
}
|
||
|
|
}
|