app/Http/Controllers/BannerController.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)
    {
        $data=request()->validate([
        'banner_header'=>'required',
        'banner_content'=>'required',
        'banner_button'=>'required',
        'carousel_icon1'=>'required',
        'carousel_icon2'=>'required',
        'banner_image'=>'required'
        ]);
        $id=auth()->user()->id;
        $imagePath = request('banner_image')->store('BannerImage', 'public');
        $image = Image::make("storage/{$imagePath}")->fit(1519, 389);
        $banner=Banner::create([
            'banner_header'=>$data['banner_header'],
            'banner_content'=>$data['banner_content'],
            'banner_button'=>$data['banner_button'],
            'carousel_icon1'=>$data['carousel_icon1'],
            'carousel_icon2'=>$data['carousel_icon2'],
            'banner_image'=>$imagePath,
            'user_id'=>$id
        ]);
        return redirect('/banner');
    }
public function store ( Request $ request ) { $ data = request ( ) -> validate ( [ 'banner_header' => 'required' , 'banner_content' => 'required' , 'banner_button' => 'required' , 'carousel_icon1' => 'required' , 'carousel_icon2' => 'required' , 'banner_image' => 'required' ] ) ; $ id = auth ( ) -> user ( ) -> id ; $ imagePath = request ( 'banner_image' ) -> store ( 'BannerImage' , 'public' ) ; $ image = Image :: make ( " storage/ { $ imagePath } " ) -> fit ( 1519 , 389 ) ; $ banner = Banner :: create ( [ 'banner_header' => $ data [ 'banner_header' ] , 'banner_content' => $ data [ 'banner_content' ] , 'banner_button' => $ data [ 'banner_button' ] , 'carousel_icon1' => $ data [ 'carousel_icon1' ] , 'carousel_icon2' => $ data [ 'carousel_icon2' ] , 'banner_image' => $ imagePath , 'user_id' => $ id ] ) ; return redirect ( '/banner' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .