events-venues/app/Models/Event.php

38 lines
753 B
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\{Builder, Factories\HasFactory, Model, Relations\BelongsTo};
class Event extends Model
{
use HasFactory;
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
public function venue(): BelongsTo
{
return $this->belongsTo(Venue::class);
}
/**
* @param Builder $query
* @param string $column
* @param string $direction
*
* @return void
*/
public function scopeSortBy(Builder $query, string $column = 'id', string $direction = 'asc'): void
{
$query->orderBy($column, validateOrderDirection($direction));
}
}