/** * Store a newly created resource in storage. * * @return Response */ public function update($id) { // Get input and save into variable. $data = Input::all(); // Validate input data. $val = AboutUs::validate($data); // If validator fails show errors to user. if ($val->fails()) { return Redirect::back()->withErrors($val); } // If no validation errors, update About Us information on database. $aboutus = AboutUs::find($id); $aboutus->title = Input::get('title'); $aboutus->body = Input::get('body'); // Get original data to compare if changes were made. $original = AboutUs::find($id); // Check if changes were made, if so, save to form, if no, redirect back with message. if ($original->title != $aboutus->title || $original->body != $aboutus->body) { $aboutus->save(); // Redirect with success message. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Information Updated Successfully!', 'success')); } else { // No changes were made, redirect back with warning message. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Nothing to update. No changes made.', 'warning')); } }
/** * Store a newly created resource in storage. * * @return Response */ public function update($id) { $input = Input::all(); $val = ContactUs::validate($input); if ($val->fails()) { return Redirect::back()->withErrors($val); } $contactus = ContactUs::find($id); $contactus->title = Input::get('title'); $contactus->address = Input::get('address'); $contactus->city = Input::get('city'); $contactus->state = Input::get('state'); $contactus->zip = Input::get('zip'); $contactus->email_1 = Input::get('email_1'); $contactus->email_2 = Input::get('email_2'); $contactus->phone_1 = Input::get('phone_1'); $contactus->phone_2 = Input::get('phone_2'); // Original record $original = ContactUs::find($id); // If nothing changed do not make call to database and return with warning message. if ($original->title != $contactus->title || $original->address != $contactus->address || $original->city != $contactus->city || $original->state != $contactus->state || $original->zip != $contactus->zip || $original->email_1 != $contactus->email_1 || $original->email_2 != $contactus->email_2 || $original->phone_1 != $contactus->phone_1 || $original->phone_2 != $contactus->phone_2) { $contactus->save(); return Redirect::back()->with('message', FlashMessage::DisplayAlert('Information Updated Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Nothing to update. No changes made.', 'warning')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $status = Status::find($id); if ($status) { try { // Delete breed, if not possible, catch error. $status->delete(); } catch (Exception $e) { // If breed to be deleted is in use, send nice error back to admin. return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status can NOT be deleted because it\'s in use.', 'alert')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Status Deleted Successfully!', 'success')); } return Redirect::back()->with('message', FlashMessage::DisplayAlert('Record Not Found.', 'alert')); }
public function updateProfile($id) { $input = Input::all(); $val = User::validate($input, $id); // If validator fails redirect back with errors for user to correct. if ($val->fails()) { return Redirect::back()->withErrors($val); } $update = User::find($id); if ($update) { $update->username = Input::get('username'); $update->email = Input::get('email'); $update->password = Hash::make(Input::get('password')); $update->save(); } else { return Redirect::back()->with('message', FlashMessage::DisplayAlert('User not found!', 'alert')); } return Redirect::to('admin/dashboard')->with('message', FlashMessage::DisplayAlert('User Profile Updated Successfully.', 'success')); }
Route::get('laravel-version', function () { $laravel = app(); return "Your Laravel version is " . $laravel::VERSION; }); //Ruta pentru pagina de login Route::get('login', function () { return View::make('login.loginform')->with('title', 'Login'); // este numele viewului login.loginform; in folderul views trebuie sa avem folderul login si in el fisierul loginform.blade.php }); //ruta pentru logarea din form Route::post('login', 'UserController@login'); //ruta pentru logout Route::get('logout', function () { Auth::logout(); Session::flush(); return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Logout succesful', 'info')); }); //ruta pentru logarea din form Route::get('signup', function () { return View::make('user.signup')->with('title', 'Signup'); }); //ruta pentru signup page Route::post('signup', 'UserController@signup'); //ruta catre formularul de forgotten [password Route::get('forgotpassword', function () { return View::make('user.forgotpassword')->with('title', 'Password Reset'); }); //Route sumit of forgotten password form to the UserController Route::post('forgotpassword', 'UserController@forgotpassword'); //Route that uses the reset code to reset a users password Route::get('resetpassword/{resetcode}', 'UserController@resetpassword');
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $event = ShelterEvent::find($id); if ($event) { $event->delete(); return Redirect::back()->with('message', FlashMessage::DisplayAlert('Event deleted successfully!', 'success')); } }
<?php // Display view (homepage) in /app/views/index.php Route::get('/', function () { return View::make('angular'); }); /* ------------------------ End User Routes --------------------------------- */ // route to show the login form Route::get('adminlogin', ['uses' => 'UserController@loginForm']); // route to process the form Route::post('adminlogin', ['uses' => 'UserController@loginPost']); // Log out user Route::get('adminlogout', function () { Auth::logout(); return Redirect::to('adminlogin')->with('message', FlashMessage::DisplayAlert('Logged out successfully', 'success')); }); /* ------------------------ End User Routes --------------------------------- */ /* --------------------------- ADMIN PREFIXED ROUTES ---------------------------- */ Route::group(['before' => 'auth', 'prefix' => '/admin'], function () { // Display dashboard view in /app/views/admin/dashboard.blade.php Route::get('dashboard', function () { return View::make('admin.dashboard')->with('title', 'Dashboard'); }); // Routes: index, create, store, show, edit, update, destroy. Route::resource('dashboard/animal', 'AnimalController'); // Route to create, view, and destroy statuses, species, and breeds. Route::get('dashboard/attributes', function () { // Get all species from database species table. $species = Species::all(); // Get all Cat breeds from database breeds table. $breeds = Breed::all();
/** * @param $resetcode */ public function resetpassword($resetcode) { $user = UserModel::where('resetcode', '=', $resetcode)->where('password_temp', '!=', ''); if ($user->count()) { //set the user variable to the first user record $user = $user->first(); $user->password = $user->password_temp; $user->password_temp = ''; $user->resetcode = ''; if ($user->save()) { return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Your account has been reset. You can now log ', 'succes')); } } else { return Redirect::to('login')->with('message', FlashMessage::DisplayAlert('Could not revover account. Please contact the admin.', 'info')); } }