app/Http/Controllers/TodoController.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)
    {
        $newtodo=new Todo();
        $newtodo->user_id=$request->user_id;
        $newtodo->todo_name=$request->todo_name;
        $newtodo->description=$request->description;
        $newtodo->estimated_delivery_time=$request->estimated_delivery_time;
        $images=[];
        if ($request->hasFile('photos')) {
            foreach ($request->photos as $key => $photo) {
                $path = $photo->store('event_images', 'public');
                $image_url= url(Storage::url($path));
                array_push($images,$image_url);
            }
        }
        $newtodo->attachments=json_encode($images);
        $newtodo->save();
        return redirect()->back()->with(['success' => 'New todo added successfully.']);
    }
public function store ( Request $ request ) { $ newtodo = new Todo ( ) ; $ newtodo -> user_id = $ request -> user_id ; $ newtodo -> todo_name = $ request -> todo_name ; $ newtodo -> description = $ request -> description ; $ newtodo -> estimated_delivery_time = $ request -> estimated_delivery_time ; $ images = [ ] ; if ( $ request -> hasFile ( 'photos' ) ) { foreach ( $ request -> photos as $ key => $ photo ) { $ path = $ photo -> store ( 'event_images' , 'public' ) ; $ image_url = url ( Storage :: url ( $ path ) ) ; array_push ( $ images , $ image_url ) ; } } $ newtodo -> attachments = json_encode ( $ images ) ; $ newtodo -> save ( ) ; return redirect ( ) -> back ( ) -> with ( [ 'success' => 'New todo added successfully.' ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .