Cleanup for settings table and moved some seed data into the migrations
This commit is contained in:
31
app/Models/Migrations/Migration.php
Normal file
31
app/Models/Migrations/Migration.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration base class with some extra functionality
|
||||
*/
|
||||
|
||||
namespace App\Models\Migrations;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Database\Migrations\Migration as MigrationBase;
|
||||
|
||||
class Migration extends MigrationBase
|
||||
{
|
||||
/**
|
||||
* Add rows to a table
|
||||
* @param $table
|
||||
* @param $rows
|
||||
*/
|
||||
public function addData($table, $rows)
|
||||
{
|
||||
foreach ($rows as $row) {
|
||||
try {
|
||||
DB::table($table)->insert($row);
|
||||
} catch (Exception $e) {
|
||||
# setting already exists
|
||||
if ($e->getCode() === 23000) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,40 +21,38 @@ class Pirep extends Model
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public $fillable
|
||||
= [
|
||||
'user_id',
|
||||
'flight_id',
|
||||
'flight_number',
|
||||
'route_code',
|
||||
'route_leg',
|
||||
'airline_id',
|
||||
'aircraft_id',
|
||||
'flight_time',
|
||||
'dpt_airport_id',
|
||||
'arr_airport_id',
|
||||
'fuel_used',
|
||||
'source',
|
||||
'level',
|
||||
'route',
|
||||
'notes',
|
||||
'status',
|
||||
'raw_data',
|
||||
];
|
||||
public $fillable = [
|
||||
'user_id',
|
||||
'flight_id',
|
||||
'flight_number',
|
||||
'route_code',
|
||||
'route_leg',
|
||||
'airline_id',
|
||||
'aircraft_id',
|
||||
'flight_time',
|
||||
'dpt_airport_id',
|
||||
'arr_airport_id',
|
||||
'fuel_used',
|
||||
'source',
|
||||
'level',
|
||||
'route',
|
||||
'notes',
|
||||
'status',
|
||||
'raw_data',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts
|
||||
= [
|
||||
'flight_time' => 'integer',
|
||||
'level' => 'integer',
|
||||
'fuel_used' => 'integer',
|
||||
'source' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
protected $casts = [
|
||||
'flight_time' => 'integer',
|
||||
'level' => 'integer',
|
||||
'fuel_used' => 'integer',
|
||||
'source' => 'integer',
|
||||
'status' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
|
||||
30
app/Models/Setting.php
Normal file
30
app/Models/Setting.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: nshahzad
|
||||
* Date: 12/9/17
|
||||
* Time: 6:24 PM
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Eloquent as Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
public $table = 'settings';
|
||||
|
||||
public $fillable = [
|
||||
'name',
|
||||
'key',
|
||||
'value',
|
||||
'group',
|
||||
'type',
|
||||
'options',
|
||||
'description',
|
||||
];
|
||||
|
||||
public $casts = [
|
||||
'options' => 'array',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user