davy_yg
2 weeks ago

Registration Controller

Posted 2 weeks ago by davy_yg

RegistrationController.php

use Hash;
use Session;
use App\User;

class RegistrationController extends Controller
{

public function index()
{
	return view('registration');
}

public function store(Request $request)
{
$this->validate($request,{
	'name' => 'required',
	'email' => 'required',		
	'password' => 'required'
};

$user = new User;
$user->name = $request->name;
$user->email = $request->email;
$user->password = Hash::make($request->password);
$user->save();

Session::flash('flash', 'Successfully add user');

return redirect()->route('admin.login');

}


?>

For the return now I wonder when do I have to use :

redirect()->route('admin.login');

and when to use:

return view('admin.login');

1 For adding data I heard it is best to use redirect()->route('admin.login');

What about return view('admin.login') ?

2 Is it for index function to show the listing data ?

3 what about update?

Is it best to use

redirect()->route('admin.login');

as well?

Please sign in or create an account to participate in this conversation.