Support the ongoing development of Laravel.io →
Database Validation

Hi. I have this table:

Schema::create('maps', function($table) {
		$table->engine = 'InnoDB';
		$table->increments('id');
		$table->string('name');
		$table->integer('coord_x');
		$table->integer('coord_y');
		$table->integer('coord_z');
		$table->unique(['coord_x', 'coord_y', 'coord_z']);
		$table->timestamps();
	});

And I want to validate the uniqueness of the 3 coords. For now I have this:

public static $rules = [
    'name' => ['required', 'between:3,29', 'unique:maps'],
    'coord_x' => ['required', 'integer'],
    'coord_y' => ['required', 'integer'],
    'coord_z' => ['required', 'integer']
];

Thanks

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.