Added some basic methods to the models to get roperties from related models or

the related models themselfes.
This commit is contained in:
Lukas Halbritter
2018-09-14 11:27:08 +02:00
parent 11775170d6
commit ac080eb485
5 changed files with 176 additions and 14 deletions
+74 -9
View File
@@ -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');
}
}