app/Http/Controllers/CategoryController.php
/**
     * Store a newly created resource in storage.
     *
     * @param Request $request
     * @return JsonResponse
     */
Store a newly created resource in storage.
@param Request $request
@return JsonResponse
Store a newly created resource in storage . @param Request $request @return JsonResponse
public function store(Request $request)
    {
        $request->validate(
            [
                'name' => 'required|unique:categories,name'
            ]
        );
        $category = Category::query()->create($request->all());
        if ($category){
            return Helper::response_with_data($category, false);
        }
        return Helper::response_with_data(null, true);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required|unique:categories,name' ] ) ; $ category = Category :: query ( ) -> create ( $ request -> all ( ) ) ; if ( $ category ) { return Helper :: response_with_data ( $ category , false ) ; } return Helper :: response_with_data ( null , true ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .