adrema/app/Course/Models/Course.php

34 lines
731 B
PHP
Raw Permalink Normal View History

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;
2021-11-18 01:54:27 +01:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Course extends Model
{
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
}