public function post_create_document() { $document_id = Input::get('document_id'); $user_id = Auth::user()->id; // we want to get all the input data // // take apart the name and value pairs // $inputs = Input::all(); //dd($inputs); foreach (Input::all() as $name => $value) { if ($name != '0' || $name != 'csrf_token') { // for some reason, laravel id=gnores form fields with nums as // the name value so this will fix it // along with the <input name="id45".. $name = str_replace('id', '', $name); Answer::create(array('document_id' => $document_id, 'user_id' => $user_id, 'field_id' => $name, 'answer' => $value)); } // dd(array( // 'document_id' => $document_id, // 'user_id' => $user_id, // 'field_id' => $key, // 'answer' => $value // )); } return Redirect::to_route('tenant_view_document', $document_id); }
public function get_erase($id) { $success = "User deleted with success!"; $user = User::find($id); $user->delete(); return Redirect::to_route('dojo::index_user')->with('success', $success); }
public function home() { // belum login if (Auth::guest()) { return Redirect::to_route('login'); } // sudah login return Request::ajax() ? View::make('pages.home') : View::make('layout'); }
public function post_multi_page_example_two() { $fields = array('street_address', 'suite_number', 'favorite_foods'); if (!ExampleForm::is_valid($fields)) { return Redirect::back()->with_input()->with_errors(ExampleForm::$validation); } ExampleForm::save_input($fields); return Redirect::to_route('form_examples', array('multi_page_example_review')); }
public function delete_destroy() { $cid = Input::get('cid'); $pid = Input::get('pid'); $post = Post::find($pid); //$post_id = Comment::find(Input::get('id'))->post->slug; Comment::find($cid)->delete(); return Redirect::to_route('post_view', $post->slug)->with('message', 'Comment has been deleted Successfully!'); }
/** * Logout dan redirect ke login form */ public function get_logout() { // Trigger: // Sebelum logout, mengkosongkan kembali isi folder 'pdf' dan 'files' dari file-file // lembar disposisi yang digenerate dan CSV yang diimport. Printpdf::empty_pdf_folder(); Suratkeluar::empty_csv_folder(); Auth::logout(); return Redirect::to_route('login')->with('title', 'Agenda Surat :: Login'); }
/** * Test the Redirect::to_route method. * * @group laravel */ public function testRedirectsCanBeGeneratedForNamedRoutes() { Route::get('redirect', array('as' => 'redirect')); Route::get('redirect/(:any)/(:any)', array('as' => 'redirect-2')); Route::get('secure/redirect', array('https' => true, 'as' => 'redirect-3')); $this->assertEquals(301, Redirect::to_route('redirect', array(), 301, true)->status()); $this->assertEquals('http://localhost/redirect', Redirect::to_route('redirect')->headers()->get('location')); $this->assertEquals('https://localhost/secure/redirect', Redirect::to_route('redirect-3', array(), 302)->headers()->get('location')); $this->assertEquals('http://localhost/redirect/1/2', Redirect::to_route('redirect-2', array('1', '2'))->headers()->get('location')); }
public function action_do_create() { $v = Customer::validate(Input::all()); if ($v->fails()) { return Redirect::to_route('create_customer')->with('user', Auth::user())->with_errors($v)->with_input(); } $new_customer = array('name' => Input::get('name'), 'description' => Input::get('description'), 'organization_id' => Auth::user()->organization->id); $customer = new Customer($new_customer); $customer->save(); return Redirect::to_route('customers'); }
public function get_logout() { if (Auth::check()) { Auth::logout(); Session::flush(); //delete the session return Redirect::to_route('home')->with('message', 'Logged out'); } else { return Redirect::to_route('home'); } }
public function delete_destroy() { $id = Input::get('id'); //*Note: Make sure to set post_id as your foreign key. //*Note: Set ON DELETE CASCADE in your comments table Post::find($id)->delete(); //*Info: Incase you didn't set your comments table "ON DELETE CASCADE", just the code below. //Post::find($id)->comments()->delete(); //Post::find($id)->delete(); return Redirect::to_route('posts')->with('message', 'Post has been deleted successfully!'); }
public function put_update() { $id = Input::get('id'); // validasi input apakah sesuai rules (cek di model "suratmasuk") $validation = Suratmasuk::validate_alt(Input::all()); if ($validation->fails()) { return Redirect::to_route('edit_suratmasuk', $id)->with_errors($validation); } else { $update_surat = Suratmasuk::update_surat($id); return Redirect::to_route('suratmasuk', $id)->with('message', $update_surat); } }
public function post_create() { $user = new User(); $user->email = Input::get('email'); $user->password = Input::get('password'); if ($user->save()) { Auth::login($user->id); return Redirect::to_route('user_account'); } else { return Redirect::to_route('home')->with('signup_errors', $user->errors->all())->with_input('only', array('email')); } }
public function action_create() { $project = Project::find(Input::get('project_id')); if (!$project || !$project->question_period_is_open()) { return Redirect::to_route('project', $project->id); } $question = new Question(array('project_id' => Input::get('project_id'), 'question' => Input::get('question'))); $question->vendor_id = Auth::user()->vendor->id; if ($question->validator()->passes()) { $question->save(); return Response::json(array("status" => "success", "question" => $question->to_array(), "html" => View::make('projects.partials.question')->with('question', $question)->render())); } else { return Response::json(array("status" => "error", "errors" => $question->validator()->errors->all())); } }
public function action_do_create() { $project = Project::find(Input::get('project_id')); $new = array('title' => Input::get('title'), 'description' => Input::get('description'), 'customer_id' => $project->customer_id, 'project_id' => $project->id, 'organization_id' => Auth::user()->organization->id); $v = Todo::validate($new); if ($v->fails()) { // redirect back to the form with // errors, input and our currently // logged in user return Redirect::to_route('create_todo', $project->id)->with_errors($v)->with_input(); } // create the new post $o = new Todo($new); $o->save(); // redirect to viewing our new post return Redirect::to_route('read_customer', $project->customer_id); }
function get_add($id = null) { if ($this->in('clear', false)) { $this->input = array(); return $this->get_clear(); } $single = $this->addGetSingle($id); if ($single === true) { $this->status('add_many'); } elseif ($single !== null) { $this->status(Cart::has($single) ? 'add_one' : 'remove', $single->to_array()); } if ($this->in('checkout', null)) { return Redirect::to_route('vanemart::checkout'); } else { return $this->back(); } }
public function action_do_create() { // let's get the new post from the POST data // this is much safer than using mass assignment $new = array('name' => Input::get('name'), 'description' => Input::get('description'), 'customer_id' => Input::get('customer_id'), 'organization_id' => Auth::user()->organization->id); $v = Project::validate($new); if ($v->fails()) { // redirect back to the form with // errors, input and our currently // logged in user return Redirect::to_route('create_project')->with('user', Auth::user())->with_errors($v)->with_input(); } // create the new post $o = new Project($new); $o->save(); // redirect to viewing our new post return Redirect::to_route('projects'); }
public function action_index() { if (Auth::check()) { if (Auth::user()->officer) { Session::reflash(); return Redirect::to_route('my_projects'); } else { Session::reflash(); if (Auth::user()->vendor && Bid::where_vendor_id(Auth::vendor()->id)->count()) { return Redirect::to_route('my_bids'); } else { return Redirect::to_route('projects'); } } } else { $view = View::make('home.index_signed_out'); } $this->layout->content = $view; }
/** * Gets the item edit page / information * * @param ModelConfig $config * @param mixed $itemId */ public function action_item($config, $itemId = false) { //try to get the object $model = ModelHelper::getModel($config, $itemId, true); //if it's ajax, we just return the item information as json //otherwise we load up the index page and dump values into if (Request::ajax()) { return eloquent_to_json($model); } else { //if the $itemId is false, we can assume this is a request for /new //if the user doesn't have the proper permissions to create, redirect them back to the model page if (!$itemId && !$config->actionPermissions['create']) { return Redirect::to_route('admin_index', array($config->name)); } $view = View::make("administrator::index", array('config' => $config, 'model' => $model)); //set the layout content and title $this->layout->content = $view; } }
public function action_create() { Session::regenerate(); $credentials = array('username' => Input::get('email'), 'password' => Input::get('password'), 'remember' => Input::has('remember') ? true : false); if (Auth::attempt($credentials)) { Auth::user()->track_signin(); if (Auth::user()->banned_at) { Auth::logout(); return Redirect::to('/')->with('errors', array(__("r.flashes.account_banned"))); } if (Input::has('modal') && Request::referrer() != route('signout')) { return Redirect::back(); } if (($url = Input::get('redirect_to')) && Input::get('redirect_to') != route('signout')) { return Redirect::to($url); } return Redirect::to('/'); } else { return Redirect::to_route('signin')->with('errors', array(__("r.flashes.login_fail")))->with('redirect_to', Request::referrer())->with_input(); } }
public function action_create() { $user_input = Input::get('user'); $user = new User(); $user->email = $user_input["email"]; $user->how_hear = $user_input["how_hear"]; $officer = new Officer(Input::get('officer')); if (in_array(strtolower($user->email), Officer::$admin_emails)) { $officer->role = Officer::ROLE_SUPER_ADMIN; } if ($user->validator(false, true)->passes() && $officer->validator()->passes()) { $user->save(); $user->officer()->insert($officer); $user->generate_reset_password_token(); Mailer::send("FinishOfficerRegistration", array("user" => $user)); return Redirect::to('/')->with('notice', 'Please check your email for a link to finish signup.'); } else { Session::flash('errors', array_merge($user->validator(false, true)->errors->all(), $officer->validator()->errors->all())); return Redirect::to_route('new_officers')->with_input(); } }
public function action_create() { $user_input = Input::get('user'); $user = new User(); $user->email = $user_input["email"]; $user->password = $user_input["password"]; $user->how_hear = $user_input["how_hear"]; $user->send_emails = isset($user_input["send_emails"]) ? true : false; $vendor = new Vendor(Input::get('vendor')); if ($user->validator()->passes() && $vendor->validator()->passes()) { $user->save(); $vendor->user_id = $user->id; $vendor->save(); $services = Input::get('services') ? array_keys(Input::get('services')) : array(); $user->vendor->services()->sync($services); Session::regenerate(); Auth::login($user->id); Mailer::send("NewVendorRegistered", array("user" => $user)); return Redirect::to('/'); } else { Session::flash('errors', array_merge($user->validator()->errors->all(), $vendor->validator()->errors->all())); return Redirect::to_route('new_vendors')->with_input(); } }
/** * This function it will analyse the new data with the old one and check what it will be updated in the defined project */ public function post_edit() { $id = Input::get('id'); $olddata = Project::find($id); $post_title = Input::get('title'); $post_body = Input::get('project_body'); $slug = Str::slug(Input::get('title')); $edit_info = array(); if (strcmp($olddata->title, $post_title) != 0) { $edit_info["title"] = $post_title; } if (strcmp($olddata->post_body, $post_body) != 0) { $edit_info["project_body"] = $post_body; } if (strcmp($olddata->slug, $slug) != 0) { $edit_info["slug"] = $slug; } $rules = array('cover' => 'image', 'slug' => 'unique:projects', 'title' => 'unique:projects|min:3|max:255'); $validation = Validator::make($edit_info, $rules); if ($validation->fails()) { return Redirect::to_route('dojo::edit_project', $id)->with_errors($validation)->with('user', $user); } else { Project::update($id, $edit_info); return Redirect::to_route('dojo::index_project'); } }
public function post_user_reset() { $input = Input::all(); $validation = User::validate_alt($input); if ($validation->fails()) { return Redirect::back()->with_errors($validation); } else { if (!User::is_last_admin($input)) { $reset = User::reset_user($input); return Redirect::to_route('settings_user')->with('message', $reset); } else { return Redirect::to_route('settings_user')->with('warning', 'Anda adalah admin terakhir, profile tidak dapat diubah menjadi user biasa.'); } } }
public function delete_undo() { // function undo_last_surat juga mereturn array value surat yg dihapus, // array tersebut kemudian dikembalikan ke form apabila diperlukan kembali $hapus = Suratkeluar::undo_last_surat(); // value dari record yang dihapus dikembalikan lagi ke form // variablenya bisa diakses dengan function Session::get('variable') return Redirect::to_route('suratkeluar')->with('alert', $hapus['pesan'])->with('tanggal', $hapus['tanggal'])->with('tujuan', $hapus['tujuan'])->with('hal', $hapus['hal'])->with('jenis', $hapus['jenis'])->with('pengirim', $hapus['pengirim']); }
protected function resetPasswordError() { return Redirect::to_route('vanemart::login')->with('ok', false)->with('reset_error', 'other'); }
/** * Function that will check if the $keyword is empty or a valid search query */ public function post_search() { $keyword = Input::get('keyword'); if (empty($keyword)) { return Redirect::to_route('dojo::index_article')->with('message', 'No keyword entered, please try again')->with('title', 'List of articles'); } return Redirect::to_route('dojo::results_article', "{$keyword}"); }
//accountingjs $assets->add('accountingjs', 'js/accounting.js'); //historyjs $assets->add('historyjs', 'js/history/native.history.js'); //and finally the admin js file $assets->add('admin', 'js/admin.js'); }); //validate_admin filter Route::filter('validate_admin', function () { //get the admin check closure that should be supplied in the config $authCheck = Config::get('administrator::administrator.auth_check'); if (!$authCheck()) { $loginUrl = URL::to(Config::get('administrator::administrator.login_path', 'user/login')); $redirectKey = Config::get('administrator::administrator.login_redirect_key', 'redirect'); $redirectUri = URL::to_route('admin_dashboard'); return Redirect::to($loginUrl)->with($redirectKey, $redirectUri); } }); //validate_model filter Route::filter('validate_model', function () { $modelName = URI::segment(2); $model = ModelHelper::getModelInstance($modelName); //if the model doesn't exist at all, redirect to 404 if (!$model) { return Response::error('404'); } //if the model does exist, check if this user has permission to access it if (!ModelHelper::checkPermission($modelName)) { Redirect::to_route('admin_dashboard'); } });
*/ Route::get('login', function () { if (Session::has('denied')) { return View::make('login')->with('denied', 'Please login to access that page'); } else { return View::make('login'); } }); Route::post('login', function () { $userdata = array('username' => Input::get('username'), 'password' => Input::get('password')); if (Auth::attempt($userdata)) { // logged in if (Auth::user()->group == 1) { return Redirect::to_route('dashboard'); } else { return Redirect::to_route(strtolower(Auth::user()->username)); } } else { return Redirect::to('login')->with('login_errors', true); } }); Route::get('logout', function () { Auth::logout(); return Redirect::to('login'); }); Route::get('dashboard', array('as' => 'dashboard', 'do' => function () { return View::make('home.index'); })); } /* |--------------------------------------------------------------------------
public function delete_destroy() { Auth::logout(); return Redirect::to_route('home'); }
protected static function parse_path($route, $regex) { $onlyRoute = self::get_route(); if (preg_match("/\\?/", $onlyRoute)) { $divider = explode("?", $onlyRoute); $params = $divider[1]; $onlyRoute = $divider[0]; } $args = array(); $object = array(); $object["args"] = array(); $object["route"] = ""; $object["valid"] = false; $validRegex = true; $redirect = false; if (preg_match("/\\//", $route)) { $split1 = explode("/", $route); $split2 = explode("/", $onlyRoute); foreach (array_keys($split1) as $key) { if (@$split1[$key] == @$split2[$key]) { $route = str_replace(@$split1[$key], @$split2[$key], $route); } if (preg_match("/\\{/", $split1[$key])) { $arg = str_replace("{", "", $split1[$key]); $arg = str_replace("}", "", $arg); if ($split1[$key] != "") { if (preg_match("/\\=/", $arg)) { $value = explode("=", $arg)[1]; $_value = explode("=", $arg)[1]; $arg = explode("=", $arg)[0]; if (isset($_GET[$arg])) { $value = $_GET[$arg]; $redirect = true; } else { if (@$split2[$key] != "") { $value = @$split2[$key]; } else { if (@$split2[$key] == "") { $value = ""; } } } if ($value == "") { $args[$arg] = $_value; } else { $args[$arg] = $value; } } else { $_value = ""; if (isset($_GET[$arg])) { $value = $_GET[$arg]; $redirect = true; } else { if (@$split2[$key] != "") { $value = @$split2[$key]; } else { if (@$split2[$key] == "") { $value = ""; } } } if ($value == "") { $args[$arg] = $_value; } else { $args[$arg] = $value; } } if (array_key_exists($arg, $regex) && $value != "") { if (!preg_match($regex[$arg], urldecode($value))) { $validRegex = false; } } $route = str_replace($split1[$key], $value, $route); } else { if (isset($split2[$key]) && $split2[$key] == "") { if (preg_match("/\\=/", $arg)) { $arg = explode("=", $arg)[0]; $value = explode("=", $arg)[1]; if (isset($_GET[$arg])) { $redirect = true; $args[$arg] = $_GET[$arg]; } else { $args[$arg] = $value; } $route = str_replace($split1[$key], $value, $route); } } } } } if ($route[strlen($route) - 1] == "/") { $split = explode("/", $route); $str = ""; foreach ($split as $r) { if ($r != "") { $str .= $r . "/"; } } $route = substr($str, 0, -1); } if ($redirect) { Redirect::to_route($route); } } $object["args"] = $args; $object["route"] = $route; if ($route == $onlyRoute && $validRegex) { $object["valid"] = true; array_push(self::$collection, 1); } else { $object["valid"] = false; array_push(self::$collection, 0); } return (object) $object; }