Esempio n. 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     //To delete the table data before creating new ones
     \App\Entities\Ano::truncate();
     \App\Entities\Ano::create(['ano' => 2014, 'ativo' => 0]);
     \App\Entities\Ano::create(['ano' => 2015, 'ativo' => 1]);
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
Esempio n. 2
0
 public function update(array $data, $ano)
 {
     //First set all entries as inactive
     $objAtivo = \App\Entities\Ano::where(["ativo" => 1])->first();
     $objAtivo->ativo = 0;
     $objAtivo->save();
     try {
         $this->validator->with($data)->passesOrFail();
         $this->repository->update($data, $ano);
         return ['error' => false];
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }