composed project, added packages, models, controllers, seeders, mirgations etc.
This commit is contained in:
37
app/Models/Event.php
Normal file
37
app/Models/Event.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements MustVerifyEmail
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
40
app/Models/Venue.php
Normal file
40
app/Models/Venue.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\{Builder, Factories\HasFactory, Model, Relations\HasMany};
|
||||
|
||||
class Venue extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user