Validations

When using unique or exists validations with a non-default database, use table('<connection>.<database>.<table>') when specifying the table name:

use Illuminate\Validation\Rule;

$input = $request->validate([
    'title' => Rule::unique(table('mysql.blog.posts')),
    'status_id' => Rule::exists(table('mysql.blog.statuses'), 'id'),
]);

Note: You have to include the connection name, otherwise Laravel thinks you are using the format <connection>.<table> rather than <database>.<table>. The default connection name is normally mysql.