Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

InvalidArgumentException on unique rule #284

Open
pedronalbert opened this issue Nov 27, 2015 · 1 comment
Open

InvalidArgumentException on unique rule #284

pedronalbert opened this issue Nov 27, 2015 · 1 comment

Comments

@pedronalbert
Copy link

I'm trying to create a unique rule but this throw "Validation rule unique requires at least 1 parameters." when save()

  public static $rules = [
    'type' => 'required',
    'state' => 'required',
    'number' => 'required|unique'
  ];
    public function store(Request $request) {
        $inputsData = $request->only('type', 'state', 'number');

        $newBus = new Bus($inputsData);

        if($newBus->save()) {
            $newBus->createSeating();

            return response()->json($newBus);
        } else {
            return response()->validation_error($newBus->errors());
        }
    }
    public function update(Request $request, $id) {
        $inputsData = $request->only('type', 'state', 'number');

        $bus = Bus::findOrFail($id);

        if($bus->updateUniques($inputsData)) {

            return response()->json($bus);
        } else {
            return response()->validation_error($bus->errors());
        }
    }
@duongtdvn
Copy link

+1 as I do get this error also, still trying to find a fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants