how to add 4 weeks in start_date and store in end_date in database

Posted 5 months ago by tanveerkhanwd
public function store(Request $request)
    {
        $numDays = 28;
        $days = $request->start_date;
        $days = addDays($numDays);
        $this->validate($request,[
            'image' => 'required',
            'name' => 'required|unique:games',
            'type' => 'required',

        ]);

        if($request->hasFile('image')){
            $image_path = $request->file('image')->store('game');
        } 
        $game = new Game;
        $game->image = $image_path;
        $game->name = $request->name;
        $game->user_id = Auth::user()->id;
        $game->start_date = $request->start_date;
        $game->end_date = $days;
        $game->description = $request->description;
        $game->bet_amount = $request->bet_amount;
        $game->type = $request->type;
        $game->save();

        return redirect()->route('game.listing')->with('success','Game store successfully');
    }

Please sign in or create an account to participate in this conversation.