Added some basic methods to the models to get roperties from related models or
the related models themselfes.
This commit is contained in:
+74
-9
@@ -6,13 +6,78 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SubBooking extends Model
|
||||
{
|
||||
/*
|
||||
* Get the booking date for a sub-booking.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function date()
|
||||
{
|
||||
return $this->belongsTo('\App\Booking', 'booking_id')->first()->date;
|
||||
}
|
||||
/**************************************************************************
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user