app/Http/Controllers/RoleController.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)
    {
        $input = $request->all();
        $validator = Validator::make($input, [
            'name' => 'required',
            'guard_name' => 'required'
        ]);   
        if($validator->fails()){
            return $this->sendError('Validation Error.', $validator->errors());       
        }
        $role = Role::create($input);
        return response()->json([
                                        'success' => true,
                                        'data'    => new RoleResource($role),
                                        'message' => 'Role created successfully.',
        ]);
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ validator = Validator :: make ( $ input , [ 'name' => 'required' , 'guard_name' => 'required' ] ) ; if ( $ validator -> fails ( ) ) { return $ this -> sendError ( 'Validation Error.' , $ validator -> errors ( ) ) ; } $ role = Role :: create ( $ input ) ; return response ( ) -> json ( [ 'success' => true , 'data' => new RoleResource ( $ role ) , 'message' => 'Role created successfully.' , ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .