Account for fuel in the finance calculations #313
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Services\DatabaseService;
|
||||
use DB;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
@@ -15,12 +14,7 @@ class YamlExport extends Command
|
||||
protected $signature = 'phpvms:yaml-export {tables*}';
|
||||
protected $description = 'YAML table export';
|
||||
|
||||
/**
|
||||
* YamlExport constructor.
|
||||
*
|
||||
* @param DatabaseService $dbSvc
|
||||
*/
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ $factory->define(App\Models\Airport::class, function (Faker $faker) {
|
||||
'lon' => $faker->longitude,
|
||||
'hub' => false,
|
||||
'ground_handling_cost' => $faker->randomFloat(2, 0, 500),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 0, 100),
|
||||
'fuel_100ll_cost' => $faker->randomFloat(2, 1, 10),
|
||||
'fuel_jeta_cost' => $faker->randomFloat(2, 1, 10),
|
||||
'fuel_mogas_cost' => $faker->randomFloat(2, 1, 10),
|
||||
];
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ $factory->define(App\Models\Flight::class, function (Faker $faker) {
|
||||
'alt_airport_id' => function () {
|
||||
return factory(App\Models\Airport::class)->create()->id;
|
||||
},
|
||||
'distance' => $faker->numberBetween(0, 1000),
|
||||
'distance' => $faker->numberBetween(1, 1000),
|
||||
'route' => null,
|
||||
'level' => 0,
|
||||
'dpt_time' => $faker->time(),
|
||||
|
||||
@@ -37,8 +37,10 @@ $factory->define(App\Models\Pirep::class, function (Faker $faker) {
|
||||
'flight_time' => $faker->numberBetween(60, 360),
|
||||
'planned_flight_time' => $faker->numberBetween(60, 360),
|
||||
'zfw' => $faker->randomFloat(2),
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 30000),
|
||||
'fuel_used' => $faker->randomFloat(2, 0, 30000),
|
||||
'block_fuel' => $faker->randomFloat(2, 0, 1000),
|
||||
'fuel_used' => function (array $pirep) {
|
||||
return round($pirep['block_fuel'] * .9, 2); // 90% of the fuel loaded was used
|
||||
},
|
||||
'block_on_time' => Carbon::now('UTC'),
|
||||
'block_off_time' => function (array $pirep) {
|
||||
return $pirep['block_on_time']->subMinutes($pirep['flight_time']);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
acars:
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_1
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: TNV
|
||||
@@ -7,7 +8,8 @@ acars:
|
||||
lon: -96.058239
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_2
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: IAH
|
||||
@@ -15,7 +17,8 @@ acars:
|
||||
lon: -95.345719
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_3
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: LCH
|
||||
@@ -23,7 +26,8 @@ acars:
|
||||
lon: -93.105569
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_4
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: MEI
|
||||
@@ -31,7 +35,8 @@ acars:
|
||||
lon: -88.804267
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_5
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: ATL
|
||||
@@ -39,7 +44,8 @@ acars:
|
||||
lon: -84.435064
|
||||
created_at: now
|
||||
updated_at: now
|
||||
- pirep_id: pirepid_1
|
||||
- id: acars_6
|
||||
pirep_id: pirepid_1
|
||||
type: 1
|
||||
nav_type: 2
|
||||
name: SIE
|
||||
|
||||
@@ -3,14 +3,4 @@
|
||||
# want to modify or erase any of this here
|
||||
#
|
||||
|
||||
airports:
|
||||
- id: KAUS
|
||||
iata: AUS
|
||||
icao: KAUS
|
||||
name: Austin-Bergstrom
|
||||
location: Austin, Texas, USA
|
||||
country: United States
|
||||
timezone: America/Chicago
|
||||
lat: 30.1945278
|
||||
lon: -97.6698889
|
||||
hub: 1
|
||||
|
||||
|
||||
@@ -452,15 +452,17 @@ pireps:
|
||||
block_off_time: 2018-04-04T12:42:36+00:00
|
||||
block_on_time: 2018-04-04T16:42:36+00:00
|
||||
flight_time: 180 # 6 hours
|
||||
block_fuel: 20000
|
||||
fuel_used: 10000
|
||||
state: 1 # accepted
|
||||
status: 0
|
||||
source: 1
|
||||
flight_type: J
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
notes: just a pilot report
|
||||
submitted_at: 2018-04-04T16:50:36+00:00
|
||||
created_at: 2018-04-04T16:50:36+00:00
|
||||
updated_at: 2018-04-04T17:00:36+00:00
|
||||
submitted_at: NOW
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: pirepid_2
|
||||
user_id: 1
|
||||
airline_id: 1
|
||||
@@ -469,6 +471,8 @@ pireps:
|
||||
dpt_airport_id: KJFK
|
||||
arr_airport_id: KAUS
|
||||
flight_time: 180 # 6 hours
|
||||
block_fuel: 20000
|
||||
fuel_used: 15000
|
||||
state: 5 # draft
|
||||
source: 0 # manual
|
||||
flight_type: J
|
||||
@@ -494,7 +498,7 @@ pireps:
|
||||
planned_flight_time: '0'
|
||||
zfw: null
|
||||
block_fuel: '21500.25390625'
|
||||
fuel_used: null
|
||||
fuel_used: 20000
|
||||
landing_rate: '0'
|
||||
score: '0'
|
||||
route: ''
|
||||
@@ -503,11 +507,11 @@ pireps:
|
||||
source_name: vmsacars
|
||||
state: 0
|
||||
status: ENR
|
||||
submitted_at: null
|
||||
block_off_time: now
|
||||
block_on_time: null
|
||||
created_at: now
|
||||
updated_at: now
|
||||
submitted_at: NOW
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
- id: pirepid_4
|
||||
user_id: 1
|
||||
airline_id: 1
|
||||
@@ -517,6 +521,8 @@ pireps:
|
||||
arr_airport_id: KAUS
|
||||
block_off_time: 2018-04-04T12:42:36+00:00
|
||||
block_on_time: 2018-04-04T16:42:36+00:00
|
||||
block_fuel: 100000
|
||||
fuel_used: 20000
|
||||
flight_time: 180 # 6 hours
|
||||
state: 0
|
||||
status: 0
|
||||
@@ -524,9 +530,9 @@ pireps:
|
||||
flight_type: J
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
notes: just a pilot report
|
||||
submitted_at: 2018-04-04T16:50:36+00:00
|
||||
created_at: 2018-04-04T16:50:36+00:00
|
||||
updated_at: 2018-04-04T17:00:36+00:00
|
||||
submitted_at: NOW
|
||||
created_at: NOW
|
||||
updated_at: NOW
|
||||
|
||||
pirep_fares:
|
||||
- id: 1
|
||||
|
||||
@@ -11,7 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Laracasts\Flash\Flash;
|
||||
use SebastianBergmann\Version;
|
||||
use PragmaRX\Version\Package\Facade as Version;
|
||||
use vierbergenlars\SemVer\version as semver;
|
||||
|
||||
class DashboardController extends Controller
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
|
||||
class Acars extends Response
|
||||
{
|
||||
/**
|
||||
@@ -9,16 +12,25 @@ class Acars extends Response
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
|
||||
$this->checkUnitFields($res, [
|
||||
'distance',
|
||||
'fuel',
|
||||
]);
|
||||
// Set these to the response units
|
||||
if (!empty($res['distance'])) {
|
||||
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
|
||||
$res['distance'] = $distance->getResponseUnits();
|
||||
}
|
||||
|
||||
if (!empty($res['fuel'])) {
|
||||
$fuel = new Fuel($res['fuel'], config('phpvms.internal_units.fuel'));
|
||||
$res['fuel'] = $fuel->getResponseUnits();
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Support\Units\Distance;
|
||||
|
||||
class Flight extends Response
|
||||
{
|
||||
/**
|
||||
@@ -19,16 +21,24 @@ class Flight extends Response
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$res = parent::toArray($request);
|
||||
|
||||
$res['ident'] = $this->ident;
|
||||
|
||||
// Return multiple measures so the client can pick what they want
|
||||
$this->checkUnitFields($res, [
|
||||
'distance',
|
||||
]);
|
||||
if (!empty($res['distance'])) {
|
||||
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
|
||||
$res['distance'] = $distance->getResponseUnits();
|
||||
}
|
||||
|
||||
$res['airline'] = new Airline($this->airline);
|
||||
$res['subfleets'] = Subfleet::collection($this->subfleets);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Enums\PirepStatus;
|
||||
use App\Support\Units\Distance;
|
||||
use App\Support\Units\Fuel;
|
||||
|
||||
class Pirep extends Response
|
||||
{
|
||||
@@ -11,6 +13,9 @@ class Pirep extends Response
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonNumericValue
|
||||
* @throws \PhpUnitsOfMeasure\Exception\NonStringUnitName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
@@ -18,11 +23,21 @@ class Pirep extends Response
|
||||
$res = parent::toArray($request);
|
||||
$res['ident'] = $this->ident;
|
||||
|
||||
$this->checkUnitFields($res, [
|
||||
'distance',
|
||||
'fuel_used',
|
||||
'planned_distance',
|
||||
]);
|
||||
// Set these to the response units
|
||||
if (!empty($res['distance'])) {
|
||||
$distance = new Distance($res['distance'], config('phpvms.internal_units.distance'));
|
||||
$res['distance'] = $distance->getResponseUnits();
|
||||
}
|
||||
|
||||
if (!empty($res['fuel_used'])) {
|
||||
$fuel_used = new Fuel($res['fuel_used'], config('phpvms.internal_units.fuel'));
|
||||
$res['fuel_used'] = $fuel_used->getResponseUnits();
|
||||
}
|
||||
|
||||
if (!empty($res['planned_distance'])) {
|
||||
$planned_dist = new Distance($res['planned_distance'], config('phpvms.internal_units.distance'));
|
||||
$res['planned_distance'] = $planned_dist->getResponseUnits();
|
||||
}
|
||||
|
||||
/*
|
||||
* Relationship fields
|
||||
|
||||
@@ -85,7 +85,7 @@ class Acars extends Model
|
||||
*
|
||||
* @return int|Distance
|
||||
*/
|
||||
public function getDistanceAttribute()
|
||||
/*public function getDistanceAttribute()
|
||||
{
|
||||
if (!array_key_exists('distance', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -103,7 +103,7 @@ class Acars extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set the distance unit, convert to our internal default unit
|
||||
@@ -126,7 +126,7 @@ class Acars extends Model
|
||||
*
|
||||
* @return int|Fuel
|
||||
*/
|
||||
public function getFuelAttribute()
|
||||
/*public function getFuelAttribute()
|
||||
{
|
||||
if (!array_key_exists('fuel', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -140,7 +140,7 @@ class Acars extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set the amount of fuel
|
||||
|
||||
@@ -17,6 +17,9 @@ use App\Models\Traits\FilesTrait;
|
||||
* @property string country
|
||||
* @property string timezone
|
||||
* @property float ground_handling_cost
|
||||
* @property float fuel_100ll_cost
|
||||
* @property float fuel_jeta_cost
|
||||
* @property float fuel_mogas_cost
|
||||
* @property float lat
|
||||
* @property float lon
|
||||
*/
|
||||
@@ -67,6 +70,9 @@ class Airport extends Model
|
||||
'lat' => 'required|numeric',
|
||||
'lon' => 'required|numeric',
|
||||
'ground_handling_cost' => 'nullable|numeric',
|
||||
'fuel_100ll_cost' => 'nullable|numeric',
|
||||
'fuel_jeta_cost' => 'nullable|numeric',
|
||||
'fuel_mogas_cost' => 'nullable|numeric',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -137,7 +137,7 @@ class Flight extends Model
|
||||
*
|
||||
* @return Distance
|
||||
*/
|
||||
public function getDistanceAttribute()
|
||||
/*public function getDistanceAttribute()
|
||||
{
|
||||
if (!array_key_exists('distance', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -152,7 +152,7 @@ class Flight extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return new Distance(0, config('phpvms.internal_units.distance', 'nmi'));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set the distance unit, convert to our internal default unit
|
||||
|
||||
@@ -35,6 +35,8 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||
* @property int block_time
|
||||
* @property int flight_time In minutes
|
||||
* @property int planned_flight_time
|
||||
* @property float block_fuel
|
||||
* @property float fuel_used
|
||||
* @property float distance
|
||||
* @property float planned_distance
|
||||
* @property string route
|
||||
@@ -124,6 +126,8 @@ class Pirep extends Model
|
||||
'flight_number' => 'required',
|
||||
'dpt_airport_id' => 'required',
|
||||
'arr_airport_id' => 'required',
|
||||
'block_fuel' => 'required|numeric',
|
||||
'fuel_used' => 'required|numeric',
|
||||
'notes' => 'nullable',
|
||||
'route' => 'nullable',
|
||||
];
|
||||
@@ -132,7 +136,6 @@ class Pirep extends Model
|
||||
* If a PIREP is in these states, then it can't be changed.
|
||||
*/
|
||||
public static $read_only_states = [
|
||||
//PirepState::PENDING,
|
||||
PirepState::ACCEPTED,
|
||||
PirepState::REJECTED,
|
||||
PirepState::CANCELLED,
|
||||
@@ -200,7 +203,7 @@ class Pirep extends Model
|
||||
*
|
||||
* @return int|Distance
|
||||
*/
|
||||
public function getDistanceAttribute()
|
||||
/*public function getDistanceAttribute()
|
||||
{
|
||||
if (!array_key_exists('distance', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -218,7 +221,7 @@ class Pirep extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set the distance unit, convert to our internal default unit
|
||||
@@ -249,7 +252,7 @@ class Pirep extends Model
|
||||
*
|
||||
* @return int|Fuel
|
||||
*/
|
||||
public function getFuelUsedAttribute()
|
||||
/*public function getFuelUsedAttribute()
|
||||
{
|
||||
if (!array_key_exists('fuel_used', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -264,14 +267,14 @@ class Pirep extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Return the planned_distance in a converter class
|
||||
*
|
||||
* @return int|Distance
|
||||
*/
|
||||
public function getPlannedDistanceAttribute()
|
||||
/*public function getPlannedDistanceAttribute()
|
||||
{
|
||||
if (!array_key_exists('planned_distance', $this->attributes)) {
|
||||
return 0;
|
||||
@@ -289,7 +292,7 @@ class Pirep extends Model
|
||||
} catch (NonStringUnitName $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Return the flight progress in a percent.
|
||||
|
||||
@@ -80,8 +80,8 @@ class JournalRepository extends Repository implements CacheableInterface
|
||||
* @param Model|null $reference The object this is a reference to
|
||||
* @param string|null $memo Memo for this transaction
|
||||
* @param string|null $post_date Date of the posting
|
||||
* @param string|null $transaction_group
|
||||
* @param array|string|null $tags
|
||||
* @param string|null $transaction_group Grouping name for the summaries
|
||||
* @param array|string|null $tags Tag used for grouping/finding items
|
||||
*
|
||||
* @throws ValidatorException
|
||||
*
|
||||
|
||||
@@ -13,7 +13,7 @@ use App\Repositories\JournalRepository;
|
||||
use App\Services\FareService;
|
||||
use App\Support\Math;
|
||||
use App\Support\Money;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class FinanceService
|
||||
@@ -70,6 +70,7 @@ class PirepFinanceService extends Service
|
||||
Log::info('Finance: Starting PIREP pay for '.$pirep->id);
|
||||
|
||||
// Now start and pay from scratch
|
||||
$this->payFuelCosts($pirep);
|
||||
$this->payFaresForPirep($pirep);
|
||||
$this->payExpensesForSubfleet($pirep);
|
||||
$this->payExpensesForPirep($pirep);
|
||||
@@ -132,6 +133,34 @@ class PirepFinanceService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the fuel used by the PIREP and add those costs in
|
||||
*
|
||||
* @param Pirep $pirep
|
||||
*
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
public function payFuelCosts(Pirep $pirep): void
|
||||
{
|
||||
$ap = $pirep->dpt_airport;
|
||||
$fuel_used = $pirep->block_fuel;
|
||||
|
||||
$debit = Money::createFromAmount($fuel_used * $ap->fuel_jeta_cost);
|
||||
Log::info('Finance: Fuel cost, (fuel='.$fuel_used.', cost='.$ap->fuel_jeta_cost.') D='
|
||||
.$debit->getAmount());
|
||||
|
||||
$this->journalRepo->post(
|
||||
$pirep->airline->journal,
|
||||
null,
|
||||
$debit,
|
||||
$pirep,
|
||||
'Fuel Cost ('.$ap->fuel_jeta_cost.'/'.config('phpvms.internal_units.fuel').')',
|
||||
null,
|
||||
'Fuel',
|
||||
'fuel'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate what the cost is for the operating an aircraft
|
||||
* in this subfleet, as-per the block time
|
||||
|
||||
@@ -37,7 +37,7 @@ class FlightExporter extends ImportExport
|
||||
|
||||
// Modify special fields
|
||||
$ret['airline'] = $ret['airline']->icao;
|
||||
$ret['distance'] = $ret['distance'][config('phpvms.internal_units.distance')];
|
||||
// $ret['distance'] = $ret['distance'][config('phpvms.internal_units.distance')];
|
||||
|
||||
$ret['dpt_airport'] = $flight->dpt_airport_id;
|
||||
$ret['arr_airport'] = $flight->arr_airport_id;
|
||||
|
||||
@@ -28,6 +28,7 @@ class MigrationService extends Service
|
||||
public function syncAllSeeds(): void
|
||||
{
|
||||
$this->syncAllSettings();
|
||||
$this->syncAllPermissions();
|
||||
}
|
||||
|
||||
public function syncAllSettings(): void
|
||||
@@ -43,6 +44,22 @@ class MigrationService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
public function syncAllPermissions(): void
|
||||
{
|
||||
$data = file_get_contents(database_path('/seeds/permissions.yml'));
|
||||
$yml = Yaml::parse($data);
|
||||
foreach ($yml as $perm) {
|
||||
$count = DB::table('permissions')->where('name', $perm['name'])->count('name');
|
||||
if ($count === 0) {
|
||||
DB::table('permissions')->insert($perm);
|
||||
} else {
|
||||
DB::table('settings')
|
||||
->where('name', $perm['name'])
|
||||
->update($perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @param $attrs
|
||||
|
||||
@@ -44,6 +44,10 @@ class Database
|
||||
{
|
||||
$imported = [];
|
||||
$yml = Yaml::parse($yml);
|
||||
if (empty($yml)) {
|
||||
return $imported;
|
||||
}
|
||||
|
||||
foreach ($yml as $table => $rows) {
|
||||
$imported[$table] = 0;
|
||||
|
||||
@@ -80,6 +84,10 @@ class Database
|
||||
$row['password'] = bcrypt($row['password']);
|
||||
}
|
||||
|
||||
if (empty($row)) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
// if any time fields are == to "now", then insert the right time
|
||||
foreach ($row as $column => $value) {
|
||||
if (strtolower($value) === 'now') {
|
||||
@@ -91,6 +99,7 @@ class Database
|
||||
DB::table($table)->insert($row);
|
||||
} catch (QueryException $e) {
|
||||
Log::error($e);
|
||||
dd($row);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user