Advertisement
loreng

[ERROR] Bentrok Use request

Jan 11th, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use App\User;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Auth;
  8. use Illuminate\Support\Facades\DB;
  9. use Illuminate\Support\Facades\Hash;
  10. use Illuminate\Support\Facades\Request;
  11.  
  12. class HomeController extends Controller
  13. {
  14.     /**
  15.      * Create a new controller instance.
  16.      *
  17.      * @return void
  18.      */
  19.     public function __construct()
  20.     {
  21.         $this->middleware('auth');
  22.     }
  23.  
  24.     /**
  25.      * Show the application dashboard.
  26.      *
  27.      * @return \Illuminate\Contracts\Support\Renderable
  28.      */
  29.     public function index()
  30.     {
  31.         return view('home');
  32.     }
  33.     public function profile()
  34.     {
  35.         return view('profile');
  36.     }
  37.     public function datUSER()
  38.     {
  39.         $daUSER = DB::table('users')
  40.         ->join('team','team.id_team','=','users.id_team')
  41.         ->get();
  42.  
  43.         return view('user.data',['daUSER'=>$daUSER]);
  44.     }
  45.     public function newUSER()
  46.     {
  47.         return view('user.new');
  48.     }
  49.     public function newUSER_action(Request $req)
  50.     {
  51.         $this->validate($req, [
  52.             'name'=>'required',
  53.             'email'=>'required|email',
  54.             'password'=>'required|min:6',
  55.             'alamat'=>'required',
  56.             'phone'=>'required',
  57.             'sec_phone'=>'required',
  58.             'place'=>'required',
  59.             'date'=>'required',
  60.             'photo'=>'required|image|mimes:jpeg,png,jpg,gif,svg'
  61.         ]);
  62.  
  63.         $user = new User;
  64.  
  65.         if($req->hashFile('photo')){
  66.             $image = $req->file('photo');
  67.             $name = time().'.'.$image->getClientOriginalExtension();
  68.             $destinationPath = public_path('/images');
  69.             $image->move($destinationPath,$name);
  70.             $this->save();
  71.  
  72.             $user->name = $req->name;
  73.             $user->address = $req->alamat;
  74.             $user->email = $req->email;
  75.             $user->password = Hash::make($req->password);
  76.             $user->photo = $name;
  77.             $user->phone = $req->phone;
  78.             $user->sec_phone = $req->sec_phone;
  79.             $user->lahir = $req->place . ' ,' . $req->date;
  80.             $user->save();
  81.  
  82.             return "SUKSES";
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement