/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     // load the create form (app/views/teams/create.blade.php)
     //return View::make('teams.create');
     $form = \DataForm::source(new Product());
     $form->add('name', trans('main.name'), 'text')->rule('required|min:2|max:255');
     $form->add('description', trans('main.description'), 'textarea')->rule('required|max:255');
     $form->add('price', trans('main.price'), 'text')->rule('integer');
     $form->add('image', trans('main.image'), 'image')->move('images/products/')->preview(300, 300)->resize(300, 300);
     $form->submit(trans('main.save'));
     $form->saved(function () use($form) {
         $form->message(trans('main.saved'));
         $form->link("dashboard/products/create", trans('main.back'));
     });
     return view('dashboard.create', compact('form'));
 }
 public function getIndex()
 {
     $form = \DataForm::source(User::find(Auth::user()->id));
     $form->add('name', 'Name', 'text')->rule('required|min:5');
     $form->add('email', 'E-mail', 'text')->rule('required|email');
     $form->add('theme', 'Theme', 'select')->options(Config::get('rapyd-dashboard::AdminLTE.themes'))->rule('required');
     $form->add('avatar', 'Avatar', 'select')->options(array_combine(Config::get('rapyd-dashboard::AdminLTE.avatar'), Config::get('rapyd-dashboard::AdminLTE.avatar')))->rule('required');
     $form->submit('Update Profile');
     $form->saved(function () use($form) {
         \Session::flash('message', array('type' => 'success', 'msg' => 'Profile updated'));
         return redirect()->action('\\Skydiver\\RapydDashboard\\Controllers\\ProfileController@getIndex');
     });
     $form->build();
     # GET USER LOGINS
     $logins = LogLogin::where('user_id', Auth::user()->id)->orderBy('updated_at', 'desc')->take(5)->get();
     return $form->view('rapyd-dashboard::profile.index', compact('form', 'logins'))->with('title', 'Edit profile');
 }
Exemplo n.º 3
0
 public function anyStyledform()
 {
     $form = \DataForm::source(Article::find(1));
     $form->add('title', 'Title', 'text')->rule('required|min:5');
     $form->add('body', 'Body', 'redactor');
     $form->add('categories.name', 'Categories', 'tags');
     $form->add('photo', 'Photo', 'image')->move('uploads/demo/')->fit(240, 160)->preview(120, 80);
     $form->submit('Save');
     $form->saved(function () use($form) {
         $form->message("ok record saved");
         $form->link("/rapyd-demo/styledform", "back to the form");
     });
     $form->build();
     return view('rapyd::demo.styledform', compact('form'));
 }