app/Http/Controllers/Backend/MyClassesController.php
/**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
Store a newly created resource in storage.
@return Response
Store a newly created resource in storage . @return Response
public function store(StoreClassroom $request)
    {
        $List_Classes = $request->List_Classes;
        try {
            $validated = $request->validated();
            foreach ($List_Classes as $List_Class) {
                $My_Classes = new Classroom();
                $My_Classes->Name_Class = ['en' => $List_Class['Name_class_en'], 'ar' => $List_Class['Name']];
                $My_Classes->Grade_id = $List_Class['Grade_id'];
                $My_Classes->save();
            }
            toastr()->success(trans('messages.success'));
            return redirect()->route('Classrooms.index');
        } catch (\Exception $e) {
            return redirect()->back()->withErrors(['error' => $e->getMessage()]);
        }
    }
public function store ( StoreClassroom $ request ) { $ List_Classes = $ request -> List_Classes ; try { $ validated = $ request -> validated ( ) ; foreach ( $ List_Classes as $ List_Class ) { $ My_Classes = new Classroom ( ) ; $ My_Classes -> Name_Class = [ 'en' => $ List_Class [ 'Name_class_en' ] , 'ar' => $ List_Class [ 'Name' ] ] ; $ My_Classes -> Grade_id = $ List_Class [ 'Grade_id' ] ; $ My_Classes -> save ( ) ; } toastr ( ) -> success ( trans ( 'messages.success' ) ) ; return redirect ( ) -> route ( 'Classrooms.index' ) ; } catch ( \ Exception $ e ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'error' => $ e -> getMessage ( ) ] ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .