控制器:
public function store(CatalogRequest $request, $collectionId)
{
$input = $request->all();
$input['collection_id'] = $collectionId;
$model = $this->model->create($input);
return redirect(cms_route('catalog.edit', [$collectionId, $model->id]))
->with('alert', fill_data('success', trans('general.created')));
}
请求:
public function rules()
{
$id = $this->route('catalog');
return [
'title' => 'required|min:2',
'slug' => 'required|min:2|unique:catalog,slug,'.$id,
];
}
错误:
array_map(): Argument #2 should be an array
in ValidationRuleParser.php line 89
如果我删除此代码“ unique:catalog,slug'。$ id”,则它正常工作
答案 0 :(得分:0)
此行将整个模型绑定到路线:
SELECT DATE_FORMAT(date, '%m/%d/%Y') AS Dates, count(*) num_entries
FROM API_phones
WHERE date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
GROUP BY Dates
ORDER BY Dates ASC
因此,既然有了模型,您就可以从中获取ID:
SELECT DATE_FORMAT(date, '%m/%d/%Y') AS Dates, COUNT(*) AS entry_count
FROM API_phones
WHERE date LIKE '%' AND date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
GROUP BY Dates
ORDER BY Dates ASC