Improved cms package code style
This commit is contained in:
parent
973d8ebc60
commit
687df3dbdd
|
|
@ -72,9 +72,9 @@ use Webkul\CMS\Repositories\CmsRepository;
|
|||
$data = request()->all();
|
||||
|
||||
$this->validate(request(), [
|
||||
'url_key' => ['required', 'unique:cms_page_translations,url_key', new \Webkul\Core\Contracts\Validations\Slug],
|
||||
'page_title' => 'required',
|
||||
'channels' => 'required',
|
||||
'url_key' => ['required', 'unique:cms_page_translations,url_key', new \Webkul\Core\Contracts\Validations\Slug],
|
||||
'page_title' => 'required',
|
||||
'channels' => 'required',
|
||||
'html_content' => 'required'
|
||||
]);
|
||||
|
||||
|
|
@ -109,13 +109,14 @@ use Webkul\CMS\Repositories\CmsRepository;
|
|||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
$this->validate(request(), [
|
||||
$locale . '.url_key' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
|
||||
if (! $this->cmsRepository->isUrlKeyUnique($id, $value))
|
||||
$locale . '.url_key' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
|
||||
if (! $this->cmsRepository->isUrlKeyUnique($id, $value)) {
|
||||
$fail(trans('admin::app.response.already-taken', ['name' => 'Page']));
|
||||
}
|
||||
}],
|
||||
$locale . '.page_title' => 'required',
|
||||
$locale . '.page_title' => 'required',
|
||||
$locale . '.html_content' => 'required',
|
||||
'channels' => 'required'
|
||||
'channels' => 'required'
|
||||
]);
|
||||
|
||||
$this->cmsRepository->update(request()->all(), $id);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ class CmsRepository extends Repository
|
|||
|
||||
foreach (core()->getAllLocales() as $locale) {
|
||||
foreach ($model->translatedAttributes as $attribute) {
|
||||
if (isset($data[$attribute]))
|
||||
if (isset($data[$attribute])) {
|
||||
$data[$locale->code][$attribute] = $data[$attribute];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,8 +101,9 @@ class CmsRepository extends Repository
|
|||
{
|
||||
$page = $this->model->whereTranslation('url_key', $urlKey)->first();
|
||||
|
||||
if ($page)
|
||||
if ($page) {
|
||||
return $page;
|
||||
}
|
||||
|
||||
throw (new ModelNotFoundException)->setModel(
|
||||
get_class($this->model), $urlKey
|
||||
|
|
|
|||
Loading…
Reference in New Issue