Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. Route::resource('users', 'UsersController');
  2.  
  3. Route::get('users/signin', 'UsersController@getSignin');
  4. Route::get('users/newaccount', 'UsersController@getSignup');
  5.  
  6. <?php
  7.  
  8. namespace AppHttpControllers;
  9.  
  10. use IlluminateHttpRequest;
  11.  
  12. use AppHttpRequests;
  13. use View;
  14. class UsersController extends Controller
  15. {
  16. public function __construct(){
  17. parent::__construct();
  18. }
  19. /**
  20. * Display a listing of the resource.
  21. *
  22. * @return IlluminateHttpResponse
  23. */
  24. public function index()
  25. {
  26. //
  27. }
  28.  
  29. /**
  30. * Show the form for creating a new resource.
  31. *
  32. * @return IlluminateHttpResponse
  33. */
  34. public function create()
  35. {
  36. return View::make('users.newaccount');
  37. }
  38.  
  39. /**
  40. * Store a newly created resource in storage.
  41. *
  42. * @param IlluminateHttpRequest $request
  43. * @return IlluminateHttpResponse
  44. */
  45. public function store(Request $request)
  46. {
  47. $validator = Validator::make(Input::all(), User::$rules);
  48.  
  49. if($validator->passes()){
  50. $user = new User;
  51. $user->name = Input::get('name');
  52. $user->email = Input::get('email');
  53. $user->password = Input::get('password');
  54. $user->save();
  55. return Redirect::to('users/signin')->with('message','Thank you for creating new account.Sign in now');
  56. }
  57. return Redirect::to('users/newaccount')->with('message','Something went wrong!')->withErrors($validator)->withInput();
  58. }
  59.  
  60. public function getSignin(){
  61. return View::make('users.signin');
  62. }
  63.  
  64.  
  65. /**
  66. * Display the specified resource.
  67. *
  68. * @param int $id
  69. * @return IlluminateHttpResponse
  70. */
  71. public function show($id)
  72. {
  73. //
  74. }
  75.  
  76. /**
  77. * Show the form for editing the specified resource.
  78. *
  79. * @param int $id
  80. * @return IlluminateHttpResponse
  81. */
  82. public function edit($id)
  83. {
  84. //
  85. }
  86.  
  87. /**
  88. * Update the specified resource in storage.
  89. *
  90. * @param IlluminateHttpRequest $request
  91. * @param int $id
  92. * @return IlluminateHttpResponse
  93. */
  94. public function update(Request $request, $id)
  95. {
  96. //
  97. }
  98.  
  99. /**
  100. * Remove the specified resource from storage.
  101. *
  102. * @param int $id
  103. * @return IlluminateHttpResponse
  104. */
  105. public function destroy($id)
  106. {
  107. //
  108. }
  109. public function getSignout(){
  110. Auth::logout();
  111. return Redirect::to('users/signin')->with('message','Signouted!');
  112. }
  113.  
  114. /*public function postSignin(){
  115. if(Auth::attempt(array('name' => Input::get('name'), 'email' => Input::get('email'), 'password'=> 'Input::get('password')))){
  116. return Redirect::to('/')->with('message','Thanks for signin');
  117. }
  118. return Redirect::to('users/singin')->with('message','Was Incorrect DATA!');
  119. } */
  120.  
  121.  
  122. }
  123.  
  124. {!! Form::open(array('url' => 'users/signin' , 'method' => 'post')) !!}
  125.  
  126. <div class="form-group">
  127. <label for="username">User Name:</label>
  128. <input type="username" class="form-control" name="name" id="name">
  129. </div>
  130.  
  131. <div class="form-group">
  132. <label for="username">Password:</label>
  133. <input type="username" class="form-control" name="password" id="name">
  134. </div>
  135.  
  136. <button type="submit" class="btn btn-default">Sign IN</button>
  137. {!! Form::close() !!}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement