public function store(StepAutocompleteRequest $request)
 {
     if (Gate::denies('store-step-autocomplete')) {
         abort(403);
     }
     $step = new StepAutocomplete();
     $step->name = $request->input('name');
     $step->save();
     return $step;
 }
 /** @test */
 public function check_list_view_for_newly_created_stepautocomplete_then_deleted()
 {
     $step = StepAutocomplete::create($this->stepAutocompleteData());
     $stepCreated = StepAutocomplete::find($step->id);
     $this->visit(action('StepAutocompleteController@index'))->see($step->name);
     $this->call('GET', action('StepAutocompleteController@destroy', [$stepCreated]), []);
     $this->dontSee($step->name);
 }
 public function queryStepAutocomplete(Request $request)
 {
     $queryStepAutocompleteName = $request->input('name');
     $step = StepAutocomplete::where('name', 'like', '%' . $queryStepAutocompleteName . '%')->get();
     return $step;
 }
 protected function importLocationStepsForContinuedIssues()
 {
     $issues = DB::connection('oldissue')->select('select * from initlaws where currentphase <> 1 and originpropid > 0');
     foreach ($issues as $issue) {
         $count = 0;
         $importSteps = DB::connection('oldissue')->select("select * from customsteps where marckfordelete = 0 and propid = {$issue->propid} order by id asc");
         if (empty($importSteps)) {
             continue;
         }
         $newLocationStep = new LocationStep();
         if (isset($importSteps[0]->optionlocation) && $importSteps[0]->optionlocation == 1) {
             $newLocationStep->location_id = 3;
         } elseif (isset($importSteps[0]->optionlocation) && $importSteps[0]->optionlocation == 2) {
             $newLocationStep->location_id = 4;
         } elseif ($importSteps[0]->lextypeid == 3 || $importSteps[0]->lextypeid == 4 || $importSteps[0]->lextypeid == 5) {
             $newLocationStep->location_id = 5;
         } else {
             $newLocationStep->location_id = 2;
         }
         $newLocationStep->issue_id = $issue->originpropid;
         $newLocationStep->step_order = 1;
         $newLocationStep->save();
         foreach ($importSteps as $importStep) {
             $newFlowStep = new FlowStep();
             $newFlowStep->id = $importStep->id;
             $newFlowStep->flow_name = StepAutocomplete::find($importStep->basestepid)->name;
             $newFlowStep->estimated_duration = $importStep->durata ? $importStep->durata : '';
             $newFlowStep->location_step_id = $newLocationStep->id;
             $newFlowStep->flowstep_order = $count++;
             $newFlowStep->start_date = $importStep->dataStart;
             $newFlowStep->end_date = $importStep->dataEnd;
             $newFlowStep->finalizat = $importStep->dataEnd ? 1 : 0;
             $translatableData = ['ro' => ['observatii' => $importStep->obsv ? $importStep->obsv : ''], 'en' => ['observatii' => $importStep->enobsv ? $importStep->enobsv : '']];
             $newFlowStep->fill($translatableData);
             $newFlowStep->save();
         }
     }
     print_r("Au fost importati: " . LocationStep::count() . " locationSteps \n cu " . FlowStep::count() . " flowSteps.");
     return true;
 }