mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-05-20 10:04:53 +00:00
cb61d9d543
🎨 Refactor `Lecturer` model to include new fields and factory usage 🔧 Update `DatabaseSeeder` to handle default seeds 🛠️ Enhance `einundzwanzig` database configuration for SQLite compatibility
61 lines
1.2 KiB
PHP
61 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class CourseEvent extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $connection = 'einundzwanzig';
|
|
|
|
/** @var list<string> */
|
|
protected $fillable = [
|
|
'from',
|
|
'to',
|
|
'course_id',
|
|
'venue_id',
|
|
'created_by',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'id' => 'integer',
|
|
'course_id' => 'integer',
|
|
'venue_id' => 'integer',
|
|
'from' => 'datetime',
|
|
'to' => 'datetime',
|
|
];
|
|
|
|
protected static function booted()
|
|
{
|
|
static::creating(function ($model) {
|
|
if (! $model->created_by) {
|
|
$model->created_by = auth()->id();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function createdBy(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function course(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Course::class);
|
|
}
|
|
|
|
public function venue(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Venue::class);
|
|
}
|
|
}
|