Answers for "laravel unique two columns"

PHP
6

laravel unique multiple columns

$table->unique(['mytext', 'user_id']);
Posted by: Guest on June-10-2020
1

composite unique between two columns laravel migration

public function up()
    {
        Schema::table('user_projects', function (Blueprint $table) {
            $table->unique(["user_id", "project_id"], 'user_project_unique');
        });
    }

    public function down()
    {
        Schema::table('user_projects', function (Blueprint $table) {
          $table->dropUnique('user_project_unique');
        });
    }
Posted by: Guest on October-09-2020
0

laravel 8 validation unique 2 columns

// in my case, just add more unique rule
'phone1' =>'string|unique:tbl_users,phone1|unique:tbl_users,phone2|different:phone2|min:2',
'phone2' =>'string|unique:tbl_users,phone2|unique:tbl_users,phone1|different:phone1|min:2',
Posted by: Guest on October-01-2021

Code answers related to "laravel unique two columns"

Browse Popular Code Answers by Language