This commit is contained in:
Nabeel Shahzad
2017-06-29 15:50:16 -05:00
parent fc1220178b
commit 0821258a2d
4 changed files with 29 additions and 9 deletions

View File

@@ -68,14 +68,9 @@ class Pirep extends Model
* Foreign Keys * Foreign Keys
*/ */
public function user() public function arr_airport()
{ {
return $this->belongsTo('App\Models\User', 'user_id'); return $this->belongsTo('App\Models\Airport', 'arr_airport_id');
}
public function flight()
{
return $this->belongsTo('App\Models\Flight', 'flight_id');
} }
public function dpt_airport() public function dpt_airport()
@@ -83,9 +78,19 @@ class Pirep extends Model
return $this->belongsTo('App\Models\Airport', 'dpt_airport_id'); return $this->belongsTo('App\Models\Airport', 'dpt_airport_id');
} }
public function arr_airport() public function fields()
{ {
return $this->belongsTo('App\Models\Airport', 'arr_airport_id'); return $this->hasMany('App\Models\PirepFieldValues', 'pirep_id');
}
public function flight()
{
return $this->belongsTo('App\Models\Flight', 'flight_id');
}
public function user()
{
return $this->belongsTo('App\Models\User', 'user_id');
} }
} }

View File

@@ -42,4 +42,13 @@ class PirepFieldValues extends Model
= [ = [
'name' => 'required', 'name' => 'required',
]; ];
/**
* Foreign Keys
*/
public function pirep()
{
return $this->belongsTo('App\Models\Pirep', 'pirep_id');
}
} }

View File

@@ -71,6 +71,11 @@ class User extends Authenticatable
return $this->belongsTo('App\Models\Airport', 'curr_airport_id'); return $this->belongsTo('App\Models\Airport', 'curr_airport_id');
} }
public function pireps()
{
return $this->hasMany('App\Models\Pirep', 'user_id');
}
public function rank() public function rank()
{ {
return $this->belongsTo('App\Models\Rank', 'rank_id'); return $this->belongsTo('App\Models\Rank', 'rank_id');

View File

@@ -32,6 +32,7 @@ class CreateUsersTable extends Migration
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
$table->index('email');
}); });
// Create table for storing roles // Create table for storing roles