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 static function boot() { parent::boot(); Type::creating(function ($type) { $type->company_id = $type->company_id ?: Auth::user()['company_id']; }); }
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; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('types')->delete(); Type::forceCreate(['entity_key' => 'entry', 'name' => 'service', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'vehicle', 'name' => 'car', 'locked' => 1, 'company_id' => 1]); Type::forceCreate(['entity_key' => 'contact', 'name' => 'user', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'contact', 'name' => 'driver', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'contact', 'name' => 'vendor', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'trip', 'name' => 'delivery', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'contact', 'name' => 'detail', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'fuel', 'name' => 'unleaded', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'fuel', 'name' => 'premium', 'company_id' => 1]); Type::forceCreate(['entity_key' => 'part', 'name' => 'tire', 'locked' => 1, 'company_id' => 1]); Type::forceCreate(['entity_key' => 'part', 'name' => 'sensor', 'company_id' => 1]); }
public function testAccessDeniedCompany() { $user = factory(\App\Entities\User::class)->create(); $user->setUp(); $this->actingAs($user); $this->visit('/type/1/edit'); $this->see(Lang::get('general.accessdenied')); $type = Type::find(1); $type->contacts()->delete(); $type->entries()->delete(); $type->models()->delete(); $type->trips()->delete(); $this->visit('/type/destroy/1'); $this->see(Lang::get('general.accessdenied')); }
public function testDelete() { $idDelete = Type::all()->last()['id']; factory(\App\Entities\Model::class)->create(['model_type_id' => $idDelete]); $this->seeInDatabase('types', ['id' => $idDelete]); $this->visit('/type/destroy/' . $idDelete)->seePageIs('/type')->see('Este registro possui refer'); $this->seeIsNotSoftDeletedInDatabase('types', ['id' => $idDelete]); $type = Type::find($idDelete); $type->contacts()->delete(); $type->entries()->delete(); $type->models()->delete(); $type->trips()->delete(); $this->seeInDatabase('types', ['id' => $idDelete]); $this->visit('/type/destroy/' . $idDelete); $this->seeIsSoftDeletedInDatabase('types', ['id' => $idDelete]); }
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; }