public function post_create() { $new_page = array('title' => trim(Input::get('title')), 'slug' => trim(Input::get('slug')), 'feature_image' => trim(Input::get('feature_image')), 'body' => trim(Input::get('body')), 'seo_title' => trim(Input::get('seo_title')), 'seo_description' => trim(Input::get('seo_description')), 'seo_keywords' => trim(Input::get('seo_keywords')), 'visibility' => trim(Input::get('visible')) ? true : false, 'author_id' => trim(Input::get('author_id'))); // set up rules for new data $rules = array('title' => 'required|min:3|max:128', 'slug' => 'unique:pages,slug', 'body' => 'required'); // make the validator $v = Validator::make($new_page, $rules); if ($v->fails()) { // redirect to form // errors return Redirect::to('user/pages/create')->with('user', Auth::user())->with_errors($v)->with_input(); } // create the new page $page = new Page($new_page); $page->save(); // add organisations to Organisation_Page foreach (Input::get('organisations') as $org_id) { $page->organisations()->attach($org_id); } // redirect to pages return Redirect::to('user/pages')->with('success', 'A new page has been created'); }