phpvms/app/Models/User.php

118 lines
3.3 KiB
PHP
Raw Normal View History

2017-06-09 02:28:26 +08:00
<?php
namespace App\Models;
2017-06-09 02:28:26 +08:00
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Contracts\Auth\CanResetPassword;
2017-06-09 02:28:26 +08:00
/**
* App\User
*
* @property integer
* $id
* @property string
* $name
* @property string
* $email
* @property string
* $password
* @property string
* $remember_token
* @property \Carbon\Carbon
* $created_at
* @property \Carbon\Carbon
* $updated_at
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[]
* $notifications
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[]
* $unreadNotifications
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereId($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereName($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereEmail($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* wherePassword($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereRememberToken($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereCreatedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\User
* whereUpdatedAt($value)
2017-06-09 02:28:26 +08:00
* @mixin \Eloquent
*/
class User extends Authenticatable
{
use Notifiable;
use EntrustUserTrait;
2017-06-09 02:28:26 +08:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable
= [
'name',
'email',
'password',
];
2017-06-09 02:28:26 +08:00
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden
= [
'password',
'remember_token',
];
protected $casts
= [
'flights' => 'integer',
'flight_hours' => 'integer',
'balance' => 'double',
'timezone' => 'integer',
];
2017-06-29 08:56:10 +08:00
2017-07-03 10:25:48 +08:00
public function pilot_id()
{
return $this->airline->code.str_pad($this->id, 3, '0', STR_PAD_LEFT);
2017-07-03 10:25:48 +08:00
}
2017-06-29 08:56:10 +08:00
/**
* Foreign Keys
*/
public function airline()
{
return $this->belongsTo('App\Models\Airline', 'airline_id');
}
public function home_airport()
{
return $this->belongsTo('App\Models\Airport', 'home_airport_id');
}
public function current_airport()
{
return $this->belongsTo('App\Models\Airport', 'curr_airport_id');
}
2017-06-30 04:50:16 +08:00
public function pireps()
{
return $this->hasMany('App\Models\Pirep', 'user_id');
}
2017-06-29 08:56:10 +08:00
public function rank()
{
return $this->belongsTo('App\Models\Rank', 'rank_id');
}
2017-06-09 02:28:26 +08:00
}