realty/app/Http/Controllers/API/v1/ImageController.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, [
            'file' => 'required|file|image|max:51200',
        ]);
        if ($request->file->isValid()) {
            $url = env('APP_URL').'/storage/'.$request->file->store('images', 'public');
            return new ImageResource(
                Image::create([
                    'url' => $url,
                ])
            );
        }
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'file' => 'required|file|image|max:51200' , ] ) ; if ( $ request -> file -> isValid ( ) ) { $ url = env ( 'APP_URL' ) . '/storage/' . $ request -> file -> store ( 'images' , 'public' ) ; return new ImageResource ( Image :: create ( [ 'url' => $ url , ] ) ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .