22 lines
388 B
PHP
22 lines
388 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Traits\Models;
|
||
|
|
|
||
|
|
/** @mixin \Illuminate\Database\Eloquent\Model */
|
||
|
|
trait HasOrder
|
||
|
|
{
|
||
|
|
public function getOrder(): int
|
||
|
|
{
|
||
|
|
$order = $this->getAttribute('order');
|
||
|
|
|
||
|
|
return is_numeric($order) ? (int) $order : 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setOrder(int $order): void
|
||
|
|
{
|
||
|
|
$this->setAttribute('order', $order);
|
||
|
|
}
|
||
|
|
}
|