app/Http/Controllers/user_controller.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'email' => 'required|unique:users',
            'username' => 'required|unique:users|alpha_dash',
            'password' => 'required|string|min:6|confirmed',
            'profile'  => 'required|image|mimes:jpeg,png,jpg',
        ]);
        $file = $request->file('profile');
        $nama_file = time() . "_" . $file->getClientOriginalName();
        $tujuan_upload = Storage::putFileAs('public/profile/', $request->file('profile'), $nama_file);
        user::create([
            'name' => $request['name'],
            'email' => $request['email'],
            'username' => $request['username'],
            'password' => bcrypt($request['password']),
            'profile' => $nama_file,
        ]);
        return redirect()->back()->withSuccess('User Created Successfully!');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required' , 'email' => 'required|unique:users' , 'username' => 'required|unique:users|alpha_dash' , 'password' => 'required|string|min:6|confirmed' , 'profile' => 'required|image|mimes:jpeg,png,jpg' , ] ) ; $ file = $ request -> file ( 'profile' ) ; $ nama_file = time ( ) . " _ " . $ file -> getClientOriginalName ( ) ; $ tujuan_upload = Storage :: putFileAs ( 'public/profile/' , $ request -> file ( 'profile' ) , $ nama_file ) ; user :: create ( [ 'name' => $ request [ 'name' ] , 'email' => $ request [ 'email' ] , 'username' => $ request [ 'username' ] , 'password' => bcrypt ( $ request [ 'password' ] ) , 'profile' => $ nama_file , ] ) ; return redirect ( ) -> back ( ) -> withSuccess ( 'User Created Successfully!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// isi dengan nama folder tempat kemana file diupload // alert()->success('Success Title', 'Success Message');