2021-08-22 19:31:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Nami;
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
trait HasNamiField
|
|
|
|
{
|
|
|
|
|
2021-11-18 19:55:03 +01:00
|
|
|
public static function nami(int $id): self
|
2021-08-22 19:31:20 +02:00
|
|
|
{
|
|
|
|
$model = static::firstWhere('nami_id', $id);
|
|
|
|
|
|
|
|
if (is_null($model)) {
|
|
|
|
throw new Exception('Nami search on '.static::class.' with ID '.$id.' failed.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|