Esempio n. 1
0
 private function addState($order, $label)
 {
     $previous = $this->states->findOneBy(['label' => $label]);
     if ($previous) {
         $this->messages[] = "~ State '{$label}' already exists and was not added.";
         return;
     }
     $state = new State();
     $state->sequence = $order;
     $state->label = $label;
     $this->states->save($state, false);
     $this->messages[] = "+ Addomg state '{$label}'.";
 }
Esempio n. 2
0
 public function handleEdit($pk, $value)
 {
     $value = Strings::trim($value);
     if (!$value) {
         $this->sendJson(['status' => 'error', 'message' => 'Název stavu nesmí být prázdný']);
     }
     $state = $this->states->findOneBy(['label' => $value]);
     if ($state) {
         $this->sendJson(['status' => 'error', 'message' => 'Již existuje stav s popiskem ' . $value]);
     }
     /** @var State $state */
     $state = $this->states->find($pk);
     if (!$state) {
         $this->sendJson(['status' => 'error', 'message' => 'Nebyl nalezen upravovaný stav']);
     }
     $state->label = $value;
     $this->states->save($state);
     $this->sendJson(['status' => 'success', 'pk' => $pk, 'new label' => $value]);
 }