Preview: Session.php
Size: 2.78 KB
/var/www/multi-event-cfp.bitkit.dk/httpdocs/app/Models/Session.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @property mixed $event_id
* @property mixed $id
* @property mixed $start_date
* @property Event $event
*/
class Session extends Model
{
use HasFactory;
protected $fillable = [
'event_id',
'title',
'description',
'category',
'start_date',
'end_date',
'type',
'room',
'hosted',
'assets',
'tags',
'color',
'hide_session',
'heading',
'sub_heading',
'description2',
'published_status',
'exclude_from_print',
'break_session',
'session_categories',
'featured_by',
'sponsored_by',
'sponsored_logo_links',
'cta_sessions',
'live_stream',
'created_from_external'
];
protected $casts = [
'start_date' => 'date:Y-m-d H:i:s',
'end_date' => 'date:Y-m-d H:i:s',
'created_at' => 'date:Y-m-d H:i:s',
'updated_at' => 'date:Y-m-d H:i:s',
'hide_session' => 'boolean',
'published_status' => 'boolean',
'exclude_from_print' => 'boolean',
'break_session' => 'boolean',
'featured_by' => 'boolean',
'sponsored_by' => 'boolean',
'session_categories' => AsArrayObject::class,
'sponsored_logo_links' => AsArrayObject::class,
'cta_sessions' => AsArrayObject::class,
'live_stream' => 'string',
'created_from_external' => 'boolean'
];
//===========================================//
//relations
public function event(): BelongsTo
{
return $this->belongsTo(Event::class);
}
public function presentation(): BelongsTo
{
// presentation call
return $this->belongsTo(Presentation::class);
}
public function getSlugNameAttribute()
{
return $this->event->slug_name;
}
public function users($role = null): BelongsToMany
{
$query = $this->belongsToMany(User::class, 'session_users')
->using(SessionUser::class)
->withPivot(['id', 'role', 'is_moderator', 'order'])
->withTimestamps()
->orderBy('session_users.order', 'asc');
if ($role)
$query->where('session_users.role', '=' . $role);
return $query;
}
public function slots(): HasMany
{
return $this->hasMany(Slot::class);
}
}
Directory Contents
Dirs: 0 × Files: 26