flight search and pagination (in admin), schema changes to accomodate

This commit is contained in:
Nabeel Shahzad
2017-11-30 20:28:45 -06:00
parent a82b8878d3
commit e1b0b92f83
30 changed files with 554 additions and 104 deletions

View File

@@ -11,9 +11,10 @@ use Eloquent as Model;
class Airport extends Model
{
public $table = 'airports';
protected $dates = ['deleted_at'];
public $timestamps = false;
public $fillable = [
'id',
'icao',
'name',
'location',
@@ -24,30 +25,28 @@ class Airport extends Model
'fuel_mogas_cost',
];
/**
* The attributes that should be casted to native types.
*
* @var array
*/
protected $casts = [
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
'icao' => 'required|unique:airports'
#'icao' => 'required|unique:airports'
];
public function save(array $options = [])
{
if(in_array('icao', $options)) {
$options['icao'] = strtoupper($options['icao']);
}
/**
* Some fancy callbacks
*/
protected static function boot() {
return parent::save($options);
parent::boot();
/**
* Make sure the ID is set to the ICAO
*/
static::creating(function (Airport $model) {
$model->icao = strtoupper($model->icao);
$model->id = $model->icao;
});
}
}