app/Http/Controllers/SubCategoryController.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(
            [
                'category_id' => 'required|exists:categories,id',
                'name' => 'required'
            ]
        );
        $subCategory = SubCategory::query()->create($request->all());
        if ($subCategory)
        {
            return Helper::response_with_data($subCategory, false);
        }
        return Helper::response_with_data(null, false);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'category_id' => 'required|exists:categories,id' , 'name' => 'required' ] ) ; $ subCategory = SubCategory :: query ( ) -> create ( $ request -> all ( ) ) ; if ( $ subCategory ) { return Helper :: response_with_data ( $ subCategory , false ) ; } return Helper :: response_with_data ( null , false ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .