protected function onGet(\Controllers\Request $input) { $id = $this->input->get('id'); $this->data['plant'] = Plant::find($id); if (!$this->data['plant']) { return $this->redirect($this->plugin->plants_url()); } return parent::onGet($input); }
protected function onAJAX(\Controllers\Request $input) { $search = $input->get('search'); if ('' == $search) { return Plant::all()->toArray(); } $plants = Plant::where('name', 'LIKE', $search . '%')->orWhere('scientific', 'LIKE', $search . '%'); if ($plants->count()) { return $plants->get()->toArray(); } $plants = Plant::where('name', 'LIKE', '%' . $search . '%')->orWhere('scientific', 'LIKE', '%' . $search . '%'); return $plants->get()->toArray(); }
protected function onGet(\Controllers\Request $input) { $this->data['plants'] = Plant::orderBy('name')->paginate(25, ['*'], 'subpage'); return parent::onGet($input); }
protected function onGet(\Controllers\Request $input) { $this->data['plants'] = Plant::all(); return parent::onGet($input); }