2021-11-18 01:54:27 +01:00
|
|
|
<?php
|
|
|
|
|
2021-11-19 22:58:27 +01:00
|
|
|
namespace App\Course\Models;
|
2021-11-18 01:54:27 +01:00
|
|
|
|
2023-02-07 02:45:15 +01:00
|
|
|
use App\Nami\HasNamiField;
|
2024-09-22 17:32:29 +02:00
|
|
|
use Database\Factories\Course\Models\CourseFactory;
|
2021-11-18 01:54:27 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Course extends Model
|
|
|
|
{
|
2024-09-22 17:32:29 +02:00
|
|
|
/** @use HasFactory<CourseFactory> */
|
2021-11-18 01:54:27 +01:00
|
|
|
use HasFactory;
|
2023-02-07 02:45:15 +01:00
|
|
|
use HasNamiField;
|
2021-11-18 01:54:27 +01:00
|
|
|
|
|
|
|
public $timestamps = false;
|
2021-11-19 22:58:27 +01:00
|
|
|
public $fillable = ['name', 'nami_id'];
|
2022-11-22 00:37:34 +01:00
|
|
|
|
|
|
|
public function getShortNameAttribute(): string
|
|
|
|
{
|
|
|
|
return str($this->name)
|
|
|
|
->trim()
|
|
|
|
->replaceFirst('Baustein', '')
|
|
|
|
->trim()
|
|
|
|
->replaceMatches('/ - .*/', '');
|
|
|
|
}
|
2023-10-18 01:11:36 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<int, array{id: int, name: string}>
|
|
|
|
*/
|
|
|
|
public static function forSelect(): array
|
|
|
|
{
|
|
|
|
return static::select('name', 'id')->get()->toArray();
|
|
|
|
}
|
2021-11-18 01:54:27 +01:00
|
|
|
}
|