multiple unique column
good evening, I have 3 tables users, jobs and finally the pivot table user_job with the pivot fields "start_date" and "end_date" and also
$table->unique('user_id','job_id','start_date')
, in my UserResource I have the following repeater:
Repeater::make('userJobs')
->label('')
->relationship()
->schema([
Select::make('job_id')
->options(Job::all()->pluck('name', 'id'))
->required()
->unique('user_job',ignoreRecord: true),
DatePicker::make('date_start')
->required()
->format('d/m/Y'),
DatePicker::make('date_end')
->format('d/m/Y'),
]),
If possible, I would like some help to respect $table->unique('user_id','job_id','start_date')
thank you in advance for your help3 Replies
I do that that but doesn't work :
->unique('user_job',ignoreRecord: true,modifyRuleUsing: function (Unique $rule,callable $get) {
return $rule
->where('date_start',$get('date_start'))
->where('job_id',$get('job_id'))
->where('user_id',$get('user_id'));
})
try this:
@bogus same problem : integrity constraint violation: 1062 Duplicate entry
any other suggestion please
please some help