public function testDelete() { $idDelete = Trip::all()->last()['id']; $this->seeInDatabase('trips', ['id' => $idDelete]); $this->visit('/trip/destroy/' . $idDelete); $this->seeIsSoftDeletedInDatabase('trips', ['id' => $idDelete]); }
public static function boot() { parent::boot(); Trip::creating(function ($trip) { $trip->company_id = $trip->company_id ?: Auth::user()['company_id']; }); }
public static function getTripsStatistics() { $trips['in_progress']['color'] = '#3871cf'; $trips['in_progress']['result'] = Trip::where('trips.pickup_date', '<=', Carbon::now())->where('trips.company_id', Auth::user()['company_id'])->where(function ($query) { $query->where('deliver_date', '>', Carbon::now())->orWhereNull('deliver_date'); })->count(); $trips['foreseen']['color'] = '#cf7138'; $trips['foreseen']['result'] = Trip::where('trips.pickup_date', '>', Carbon::now())->where('trips.company_id', Auth::user()['company_id'])->count(); $trips['accomplished']['color'] = '#38cf71'; $trips['accomplished']['result'] = Trip::where('trips.deliver_date', '<=', Carbon::now())->where('trips.company_id', Auth::user()['company_id'])->count(); return $trips; }
public function testDeleteExecutive() { $this->get('/trip/destroy/' . Trip::all()->last()['id'])->assertResponseStatus(302); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('trips')->delete(); Trip::forceCreate(['driver_id' => 3, 'vehicle_id' => 1, 'vendor_id' => 2, 'trip_type_id' => 6, 'pickup_date' => '2016-01-01', 'deliver_date' => '2016-01-01', 'pickup_place' => '1200 First Av', 'deliver_place' => '345 63th St', 'begin_mileage' => 320, 'end_mileage' => 450, 'total_mileage' => 130, 'fuel_cost' => 15, 'fuel_amount' => 5, 'description' => 'Descricao Trip', 'company_id' => 1]); }