【发布时间】:2019-05-27 07:45:54
【问题描述】:
在我的 Web 应用程序中,我有位置,每个位置都有 company_id,我不想在同一家公司有相同的位置名称。所以我做了这个:
$name = $request->get('name');
$location = Location::find($id);
if ($location->name != $name) {
$old_location = Location::where('company_id', $location->company_id)
->where('name', $name)
->first();
if ($old_location) {
$errors = ['name' => trans('asset.location').' '.$name.'
'.trans('message.already_exists')];
return back()->withErrors($errors)->withInput();
}
}
问题是,如果我有Service 位置并想将其名称更改为Šervice,它不会让我这样做。我没有这样命名的位置。如果条件通过但在雄辩的搜索中失败。这怎么可能?
【问题讨论】:
标签: laravel