2019-06-17 09:22:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
2019-09-12 11:08:25 +02:00
|
|
|
namespace App\Models;
|
2019-06-17 09:22:10 +02:00
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class Etiquette extends Model
|
|
|
|
|
{
|
2022-04-19 16:07:27 +02:00
|
|
|
/**
|
|
|
|
|
* The primary key associated with the table.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $primaryKey = 'etiquette_id';
|
2019-07-11 11:45:47 +02:00
|
|
|
|
2022-06-20 14:57:58 +02:00
|
|
|
// * RELATIONSHIPS
|
|
|
|
|
|
2022-04-19 16:07:27 +02:00
|
|
|
/**
|
2022-06-20 14:57:58 +02:00
|
|
|
* HasMany media relation
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
|
|
|
*/
|
|
|
|
|
public function mediaList()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Media::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// * METHODS
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get no label
|
|
|
|
|
*
|
|
|
|
|
* @return self
|
|
|
|
|
* @throws \RuntimeException If fetching default label no label fails.
|
2022-04-19 16:07:27 +02:00
|
|
|
*/
|
2022-06-20 14:57:58 +02:00
|
|
|
public static function getDefaultEtiquette(): self
|
2022-04-19 16:07:27 +02:00
|
|
|
{
|
2022-06-20 14:57:58 +02:00
|
|
|
return self::whereEtiquetteId(0)->first() ??
|
|
|
|
|
throw new \RuntimeException('Failed to fetch label no label');
|
2022-04-19 16:07:27 +02:00
|
|
|
}
|
2019-06-17 09:22:10 +02:00
|
|
|
}
|