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 onAJAX(\Controllers\Request $input) { return Plant::all()->toArray(); }
protected function onGet(\Controllers\Request $input) { $this->data['plants'] = Plant::all(); return parent::onGet($input); }