module shop crud
This commit is contained in:
@ -132,9 +132,9 @@ class Slug
|
||||
* @param $model
|
||||
* @return string
|
||||
*/
|
||||
public static function createSlug(string $title, $model = null): string
|
||||
public static function createSlug(string $data, $model = null): string
|
||||
{
|
||||
$slug = Slug::url_slug($title, ['transliterate' => true, 'lowercase' => true]);
|
||||
$slug = Slug::url_slug($data, ['transliterate' => true, 'lowercase' => true]);
|
||||
if ($model === null) {
|
||||
return $slug;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class PostController extends AdminController
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public function actionIndex($page_number = 1): void
|
||||
public function actionIndex(int $page_number = 1): void
|
||||
{
|
||||
$this->cgView->render("index.php", ['page_number' => $page_number]);
|
||||
}
|
||||
@ -50,7 +50,7 @@ class PostController extends AdminController
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionView($id): void
|
||||
public function actionView(int $id): void
|
||||
{
|
||||
$content = Post::find($id);
|
||||
|
||||
@ -63,7 +63,7 @@ class PostController extends AdminController
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionUpdate($id): void
|
||||
public function actionUpdate(int $id): void
|
||||
{
|
||||
$model = Post::find($id);
|
||||
if (!$model){
|
||||
@ -76,17 +76,16 @@ class PostController extends AdminController
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionEdit($id): void
|
||||
public function actionEdit(int $id): void
|
||||
{
|
||||
$post = Post::find($id);
|
||||
if (!$post){
|
||||
throw new Exception(message: "The post not found");
|
||||
}
|
||||
$postForm = new CreatePostForm();
|
||||
$postService = new PostService();
|
||||
$postForm->load($_REQUEST);
|
||||
if ($postForm->validate()) {
|
||||
$post = $postService->update($postForm, $post);
|
||||
$post = $this->postService->update($postForm, $post);
|
||||
if ($post) {
|
||||
$this->redirect("/admin/post/" . $post->id);
|
||||
}
|
||||
@ -94,9 +93,15 @@ class PostController extends AdminController
|
||||
$this->redirect("/admin/post/update/" . $id);
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionDelete($id): void
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
#[NoReturn] public function actionDelete(int $id): void
|
||||
{
|
||||
$post = Post::find($id)->first();
|
||||
if (!$post){
|
||||
throw new Exception(message: "The post not found");
|
||||
}
|
||||
$post->delete();
|
||||
$this->redirect("/admin/post/");
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class AdminThemeService
|
||||
public function setActiveAdminTheme(string $theme): void
|
||||
{
|
||||
$active_admin_theme = Option::where("key", "active_admin_theme")->first();
|
||||
Debug::prn(getConst($theme));
|
||||
$active_admin_theme->value = getConst($theme);
|
||||
$active_admin_theme->save();
|
||||
}
|
||||
|
Reference in New Issue
Block a user