app/Http/Controllers/EventController.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)
    {
        $request->validate([
            'title' => 'required|max:100',
            'venue' => 'required',
            'date' => 'required',
            'description' => 'required',
            'image' => 'required|image|max:2048|mimes:jpeg,jpg,bmp,png,gif,svg'
        ]);
        $image = $request->file('image');
        $new_name = rand() . '.' . $image->getClientOriginalExtension();
        $image->move(public_path('images'), $new_name);
        $form_data = array(
            'title' => $request->title,
            'venue' => $request->venue,
            'date' => $request->date,
            'description' => $request->description,
            'image' => $new_name,
        );
        Event::create($form_data,  $request->all());
        return redirect()->route('events.index')
            ->with('success', 'Events created succesfully.');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'title' => 'required|max:100' , 'venue' => 'required' , 'date' => 'required' , 'description' => 'required' , 'image' => 'required|image|max:2048|mimes:jpeg,jpg,bmp,png,gif,svg' ] ) ; $ image = $ request -> file ( 'image' ) ; $ new_name = rand ( ) . '.' . $ image -> getClientOriginalExtension ( ) ; $ image -> move ( public_path ( 'images' ) , $ new_name ) ; $ form_data = array ( 'title' => $ request -> title , 'venue' => $ request -> venue , 'date' => $ request -> date , 'description' => $ request -> description , 'image' => $ new_name , ) ; Event :: create ( $ form_data , $ request -> all ( ) ) ; return redirect ( ) -> route ( 'events.index' ) -> with ( 'success' , 'Events created succesfully.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//dd($request->all());