57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use App\Library\SeatNamePrinter;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SingleSeatsUser extends Model
|
|
{
|
|
protected $fillable = ['user_id', 'single_seat_id', 'event_concessions_id', 'paymentmethod_id', 'order_id'];
|
|
protected $table = 'single_seat_user';
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
|
|
static::deleting(function ($ssu) {
|
|
if($ssu->singleSeat != null && $ssu->singleSeat->culturecardTicket != null)
|
|
$ssu->singleSeat->culturecardTicket->delete();
|
|
});
|
|
}
|
|
|
|
/* RELATIONS */
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User', 'user_id');
|
|
}
|
|
|
|
public function singleSeat()
|
|
{
|
|
return $this->belongsTo('App\SingleSeat', 'single_seat_id');
|
|
}
|
|
|
|
public function paymentmethod()
|
|
{
|
|
return $this->belongsTo('App\Paymentmethod', 'paymentmethod_id');
|
|
}
|
|
|
|
public function concession()
|
|
{
|
|
return $this->belongsTo('App\Concession', 'event_concessions_id');
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo('App\Order', 'order_id');
|
|
}
|
|
|
|
public function calcSeatName()
|
|
{
|
|
$seatNamePrinter = new SeatNamePrinter($this);
|
|
return $seatNamePrinter->calcSeatName();
|
|
}
|
|
}
|