/** * Get all validation rules for update for given id. * * @param \Illuminate\Database\Eloquent\Model|integer|string $id * @return array */ public static function getUpdateRulesForId($id) { return rules_for_update(static::getCreateRules(), $id, (new static())->getKeyName()); }
/** * @test */ public function rules_for_update_helper() { $rules = ['email' => 'required|email|unique:users', 'name' => ['required', 'max:10', 'unique:users,username,null,id,account_id,5']]; $rulesAdjusted = ['email' => ['required', 'email', 'unique:users,email,10,primary_key'], 'name' => ['required', 'max:10', 'unique:users,username,10,primary_key,account_id,5']]; $this->assertEquals($rulesAdjusted, rules_for_update($rules, 10, 'primary_key')); }