public function anyIndex() { // load the data $model = Article::findOrNew(1); // instantiate the form $form = new Endpoint($model); // define the fields $form->text('title')->rules('required|max:10'); $form->text('author.firstname', 'Author\'s first name')->rules('required'); $form->text('author.lastname'); $form->textarea('detail.note'); $form->textarea('body'); $form->select('public')->options([0 => 'No', 1 => 'Yes']); // read the POST data, if any $form->populate(); // write new data back to the model $form->writeSource(); // if the form has been sent, and has no errors if ($form->submitted() && $form->validate()) { // we will save the data in the database $form->save(); } // we just need to pass the $form instance to the view return $form->toArray(); }
/** * A very simple grid. */ public function anyIndex() { $grid = new Grid(Article::with('categories')->with('author')); $grid->text('id'); $grid->text('title'); $grid->text('author.fullname'); $grid->text('categories', 'In category')->value(function ($v) { if ($v instanceof Collection) { return implode(', ', $v->lists('name')); } }); $grid->select('public')->options([1 => 'Yes']); $grid->start->before[] = '<p><em>This is a very simple grid</em></p>'; return View::make('bees::demo.grid-automatic', compact('grid')); }
public function anyIndex() { try { Article::find(1); } catch (QueryException $e) { return ' <div style="text-align: center;margin-top: 100px;"> <p><strong>Database error!</strong></p> <p> </p> <ol style="text-align: left;width: 300px; display: inline-block;"> <li>create a database that matches your config files</li> <li><a href="/demo/setup">seed the DEMO database</a></li> </ol> </div> '; } return \Redirect::action('\\Tacone\\Bees\\Demo\\Controllers\\FormController@anyIndex'); }