public function addAction() { $os = new OperatingSystems(); $os->name = $this->request->getPost('name'); $os->save(); $this->flash->success("New OS was added."); $this->dispatcher->forward(['action' => 'index']); }
public function addAction() { $phones = new Phones(); $producer = PhonesProducers::findFirst("name = '" . $this->request->getPost('producer') . "'"); $producerId = $producer->id; $phones->producer_id = $producerId; $OS = OperatingSystems::findFirst("name = '" . $this->request->getPost('OS') . "'"); $OSId = $OS->id; $phones->operating_system_id = $OSId; $phones->model = $this->request->getPost('model'); $phones->save(); $this->flash->success("Phone was successfully added."); $this->dispatcher->forward(['action' => 'index']); }