paginate($request->query("page", 1)); return view("user.index", [ "users" => $users ]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function create() { return view("user.create"); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function store(Request $request) { $data = $request->validate([ "name_first" => "required|max:255", "name_last" => "required|max:255", "email" => "required|email|unique:users", "password" => "required|max:60", "phone" => "required|unique:users", ]); $user = new User($data); $user->save(); return view("user.success"); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show($id) { $user = User::find($id); return view("user.show", [ "user" => $user ]); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function edit($id) { $user = User::find($id); return view("user.edit", [ "user" => $user ]); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } /*******************************************/ /* Authentication */ /*******************************************/ public function login(Request $request) { $data = $request->only("email", "password"); if(Auth::attempt($data)) { return view("user.home", [ "user" => Auth::user() ]); } return redirect()->back(400); } }