@danielzepp not sure what you mean, I have use App\Template in both the Request and Controller classes
in my Controller I have
public function update(Template $template, TemplateRequest $request)
in my RouteServiceProvider I have
Route::model('Template', App\Template::class);
OK found the trick. Here is the solution. I use segment to identify the slug to ignore then also ensure I scope the query to multitenancy.
$id = $this->segment(4);
$rules =
[
'name'=>'required',
'template'=>'required',
'location'=>[
'required',
Rule::unique('templates')->where(function ($query) {
$uid = Auth::user()->id;
$query->where('user_id',$uid);
})->ignore($id,'slug')
],
'min_count'=>'required|numeric',
'template'=>'required',
];
return $rules;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community