public function testUpdate() { $fuelType = Type::where('entity_key', 'fuel')->where('name', 'premium')->first(); $this->visit('/trip/' . Trip::all()->last()['id'] . '/edit'); $this->type('01/02/2016 15:15:15', 'pickup_date')->type('02/02/2016 15:15:15', 'deliver_date')->type('1220 First Av', 'pickup_place')->type('342 63th St', 'deliver_place')->type('322', 'begin_mileage')->type('452', 'end_mileage')->type('132', 'total_mileage')->type('13.20', 'fuel_cost')->type('20.00', 'fuel_amount')->type('Descricao2', 'description')->type($fuelType->id, 'fuel_type')->select('1', 'tank_fill_up')->press('Enviar')->seePageIs('/trip'); $this->seeInDatabase('trips', ['pickup_date' => '2016-02-01 15:15:15', 'deliver_date' => '2016-02-02 15:15:15', 'pickup_place' => '1220 First Av', 'deliver_place' => '342 63th St', 'begin_mileage' => 322, 'end_mileage' => 452, 'total_mileage' => 132, 'fuel_cost' => 13.2, 'fuel_amount' => 20, 'fuel_type' => $fuelType->id, 'tank_fill_up' => 1, 'description' => 'Descricao2']); }
public function setInputs($inputs) { $typeId = Type::where('entity_key', 'contact')->where('name', 'detail')->where('company_id', Auth::user()['company_id'])->first(); $inputs['contact_type_id'] = $typeId->id; $inputs['limit_temperature'] = HelperRepository::money($inputs['limit_temperature']); $inputs['ideal_pressure'] = HelperRepository::money($inputs['ideal_pressure']); $inputs['delta_pressure'] = HelperRepository::money(substr($inputs['delta_pressure'], 0, -1)); return $inputs; }
public function createContact($name, $company_id) { $typeDetail = Type::where('entity_key', 'contact')->where(function ($query) { $query->where('name', Lang::get('setup.detail'))->orWhere('name', 'detail'); })->where('company_id', $company_id)->first(); $contactUser = Contact::forceCreate(['company_id' => $company_id, 'contact_type_id' => $typeDetail->id, 'name' => $name]); $contactUser->save(); $this->contact_id = $contactUser->id; $this->save(); return $contactUser; }
public function setInputs($inputs, $user = null) { $typeId = Type::where('entity_key', 'contact')->where('name', 'detail')->where('company_id', Auth::user()['company_id'])->first(); $inputs['contact_type_id'] = $typeId->id; if (!empty($user) && empty($user->password)) { unset($inputs['email']); unset($inputs['password']); } elseif (!empty($user->password) && !empty($inputs['password']) || empty($user)) { $inputs['password'] = Hash::make($inputs['password']); } elseif (!empty($user) && empty($inputs['password'])) { unset($inputs['password']); } return $inputs; }
public static function getTypes($entity_key = null) { $types = Type::where('company_id', Auth::user()['company_id']); if (!empty($entity_key)) { $types = $types->where('entity_key', $entity_key); } $types = $types->lists('name', 'id'); if (!empty($types)) { foreach ($types as $index => $type) { if (Lang::has('general.' . $type)) { $types[$index] = Lang::get('general.' . $type); } } } return $types; }