Files
pollux/app/SubBooking.php
T

89 lines
2.5 KiB
PHP

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class SubBooking extends Model
{
public function signedAmount()
{
return $this->ioType->factor * $this->amount;
}
/**************************************************************************
* BOOKINGS *
**************************************************************************/
/*
* Get the booking which contains the sub-booking.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function booking() {
return $this->belongsTo('\App\Booking', 'booking_id');
}
/*
* Get the booking date for a sub-booking.
*
* @return string
*/
public function date()
{
return $this->booking->date;
}
/**************************************************************************
* ACCOUNT TYPES *
**************************************************************************/
/*
* Get the account type related to the sub-booking.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function accountType()
{
return $this->belongsTo('App\AccountType', 'account_type_id');
}
/*
* Get the IO-type of the sub-booking.
*
* @return
*/
public function ioType()
{
return $this->accountType->ioType();
}
/**************************************************************************
* PERSON TARGETS *
**************************************************************************/
/*
* Get the person-target related to the sub-booking.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function personTarget()
{
return $this->belongsTo('App\PersonTarget', 'person_target_id');
}
/**************************************************************************
* PROJECTS *
**************************************************************************/
/*
* Get the project related to the sub-booking.
*
* @return Illuminate\Database\Eloquent\Relations\belongsTo
*/
public function project()
{
return $this->belongsTo('App\Project', 'project_id');
}
}