'display', 'create' => 'display']; /** * @var string */ protected $title; public function initialize() { $this->creating(function ($config, Model $model) { }); } /** * @var string */ protected $alias; /** * @return DisplayInterface */ public function onDisplay() { $form = AdminDisplay::datatablesAsync()->setDisplaySearch(true) ->setOrder([[0, 'desc']]) ->setHtmlAttribute('class', 'table-primary') ->setColumns( AdminColumn::link('id', '#')->setWidth('30px'), AdminColumnEditable::text('lat', 'lat')->setWidth('100px'), AdminColumnEditable::text('lng', 'lng')->setWidth('100px'), AdminColumnEditable::text('created_at', 'Date')->setWidth('100px') )->paginate(20); $filters = request()->get('payload', []); Log::info($filters); if (! empty($filters['user_id'])) { $userId = $filters['user_id']; $form->setApply(function ($query) use ($userId) { $query->where('user_id', $userId); }); } return $form; } /** * @param int $id * * @return FormInterface */ public function onEdit($id) { $users = []; foreach (User::all() as $user) { $users[$user->id] = $user['name']; } $formElements = [ AdminFormElement::select('user_id', 'User', $users), AdminFormElement::columns() ->addColumn(function () { return [ AdminFormElement::text('lat', 'lat') ]; }) ->addColumn(function () { return [ AdminFormElement::text('lng', 'lng') ]; }) ]; $form = AdminForm::panel(); $form->addBody($formElements); $form->getButtons()->setButtons([ 'save' => new Save(), 'cancel' => new Cancel(), ]); return $form; } /** * @return FormInterface */ public function onCreate() { return $this->onEdit(null); } /** * @return void */ public function onDelete($id) { // remove if unused } /** * @return void */ public function onRestore($id) { // remove if unused } }