ldc-dam/app/Models/Etiquette.php

42 lines
823 B
PHP
Raw Permalink Normal View History

2019-06-17 09:22:10 +02:00
<?php
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';
// * RELATIONSHIPS
2022-04-19 16:07:27 +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
*/
public static function getDefaultEtiquette(): self
2022-04-19 16:07:27 +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
}