src/Http/Controllers/CmsCategoryController.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)
    {
        $validatedData = $request->validate([
            'name' => ['required', 'max:60', 'unique:cms_categories,name'],
        ]);
        try {
            $data = CmsCategory::create($validatedData);
            return redirect(route('posts.categories.index'))->with('status', 'category ' . $data->name . ' created successfully');
        } catch (\Throwable $th) {
            return redirect()->back()->with('error', 'Something went wrong ' . $th->getMessage());
        }
    }
public function store ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'name' => [ 'required' , 'max:60' , 'unique:cms_categories,name' ] , ] ) ; try { $ data = CmsCategory :: create ( $ validatedData ) ; return redirect ( route ( 'posts.categories.index' ) ) -> with ( 'status' , 'category ' . $ data -> name . ' created successfully' ) ; } catch ( \ Throwable $ th ) { return redirect ( ) -> back ( ) -> with ( 'error' , 'Something went wrong ' . $ th -> getMessage ( ) ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .