app/Http/Controllers/Api/UserAvatarController.php
/**
     * Store a new user avatar.
     *
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
     */
Store a new user avatar.
Store a new user avatar .
public function store()
    {
        request()->validate([
            'avatar' => ['required', 'image']
        ]);
        auth()->user()->update([
            'avatar_path' => request()->file('avatar')->store('avatars', 'public')
        ]);
        return response([], 204);
    }
public function store ( ) { request ( ) -> validate ( [ 'avatar' => [ 'required' , 'image' ] ] ) ; auth ( ) -> user ( ) -> update ( [ 'avatar_path' => request ( ) -> file ( 'avatar' ) -> store ( 'avatars' , 'public' ) ] ) ; return response ( [ ] , 204 ) ; }
Store a new user avatar.
Store a new user avatar .