app/Http/Controllers/GalerieController.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)
    {
        $validator = $request->validate([
            'files' =>'required|max:2000',
            'files.*'=>'mimes:jpeg,png,jpg,gif,svg|max:2000',
        ]); 
              $photo = new Galerie();
                $photo->service_id = $request->input('boutique_id');
                $photo->titre = $request->input('nomProduit');
                $photo->disponibilité = 1;
                $photo->prix = $request->input('prix');
                $photo->description= $request->input('description');
                if($request->hasfile('photo')){
                  $photo->photo = $request->file('photo')->storeAs('galerie',$request->file('photo')->getClientOriginalName());
                }
              $photo->save();
         if(!is_null($photo)) {
            return back()->with('success', "Produit ajouter avec succés");
         }
         else {
             return back()->with('failed', 'Erreur! Veuillez réessayer');
         }
    }
public function store ( Request $ request ) { $ validator = $ request -> validate ( [ 'files' => 'required|max:2000' , 'files.*' => 'mimes:jpeg,png,jpg,gif,svg|max:2000' , ] ) ; $ photo = new Galerie ( ) ; $ photo -> service_id = $ request -> input ( 'boutique_id' ) ; $ photo -> titre = $ request -> input ( 'nomProduit' ) ; $ photo -> disponibilité  ; $ photo -> prix = $ request -> input ( 'prix' ) ; $ photo -> description = $ request -> input ( 'description' ) ; if ( $ request -> hasfile ( 'photo' ) ) { $ photo -> photo = $ request -> file ( 'photo' ) -> storeAs ( 'galerie' , $ request -> file ( 'photo' ) -> getClientOriginalName ( ) ) ; } $ photo -> save ( ) ; if ( ! is_null ( $ photo ) ) { return back ( ) -> with ( 'success' , " Produit ajouter avec succés" ) ; } else { return back ( ) -> with ( 'failed' , 'Erreur! Veuillez réessayer') ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .