See if this works,
$this->validate($request, [
'subject' => ['required'],
'name' => ['required', Rule::unique('exam','name')
->ignore($this->route('id'))
->where(function($q){
$q->where('subject', $this->get('subject'));
})
]);
Class 'App\Http\Controllers\Rule' not found
$this->validate($requ- list text hereest, [ 'subject' => ['required'], 'name' => ['required', Rule::unique('exam','name') ->ignore($this->route('id')) ->where(function($q){ $q->where('subject', $this->get('subject')); }) ]);
so i put this use Illuminate\Validation\Rule;
but now i'm getting this error
Method [route] does not exist.
http://aice.webtutorialguru.com/faltu/db.jpg here is a preview of the table. please have a look
i want the combination of the "name" and "subjectId" to be unique in "exam" table
thanks for you answer
Ok I see.
Hopefully This should work.
$this->validate($request, [
'subject' => ['required'],
'name' => [
'required',
Rule::unique('exam','name')
->ignore($request->route('id'))
->where(function($q) use ($request){
$q->where('subjectId', $request->get('subjectId'));
}),
]);
Change the query inside the where closure as you need.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community