Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions app/Http/Controllers/Admin/AdminCategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Category\StoreRequest;
use App\Http\Requests\Admin\Category\UpdateRequest;
use App\Models\Category;
use Illuminate\Support\Str;

class AdminCategoryController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$categories = Category::all();

return view('admin.category.index', ['categories' => $categories]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.category.create');
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreRequest $request)
{
$data = $request->validated();
$data['slug'] = Str::slug($data['title']);
/** @phpstan-ignore-next-line */
Category::firstOrCreate($data);

return redirect()->route('admin.category.index');
}

/**
* Display the specified resource.
*/
public function show(Category $category)
{
return view('admin.category.show', ['category' => $category]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Category $category)
{
return view('admin.category.edit', ['category' => $category]);
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, Category $category)
{
$data = $request->validated();
$category->update($data);

return view('admin.category.show', ['category' => $category]);
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Category $category)
{
$category->delete();

return redirect()->route('admin.category.index');
}
}
93 changes: 93 additions & 0 deletions app/Http/Controllers/Admin/AdminPostController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Post\StoreRequest;
use App\Http\Requests\Admin\Post\UpdateRequest;
use App\Models\Category;
use App\Models\Post;
use App\Models\Tag;
use App\Service\PostService;

class AdminPostController extends Controller
{
public $service;

public function __construct(PostService $service)
{
$this->service = $service;
}

/**
* Display a listing of the resource.
*/
public function index()
{
$posts = Post::all();

return view('admin.post.index', ['posts' => $posts]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
$categories = Category::all();
$tags = Tag::all();

return view('admin.post.create', ['categories' => $categories, 'tags' => $tags]);
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreRequest $request)
{
$data = $request->validated();
$this->service->store($data);

return redirect()->route('admin.post.index');
}

/**
* Display the specified resource.
*/
public function show(Post $post)
{
return view('admin.post.show', ['post' => $post]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Post $post)
{
$categories = Category::all();
$tags = Tag::all();

return view('admin.post.edit', ['post' => $post, 'categories' => $categories, 'tags' => $tags]);
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, Post $post)
{
$data = $request->validated();
$post = $this->service->update($data, $post);

return redirect()->route('admin.post.show', ['post' => $post]);
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Post $post)
{
$post->delete();

return redirect()->route('admin.post.index');
}
}
78 changes: 78 additions & 0 deletions app/Http/Controllers/Admin/AdminTagController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Tag\StoreRequest;
use App\Http\Requests\Admin\Tag\UpdateRequest;
use App\Models\Tag;

class AdminTagController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$tags = Tag::all();

return view('admin.tag.index', ['tags' => $tags]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.tag.create');
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreRequest $request)
{
$data = $request->validated();
/** @phpstan-ignore-next-line */
Tag::firstOrCreate($data);

return redirect()->route('admin.tag.index');
}

/**
* Display the specified resource.
*/
public function show(Tag $tag)
{
return view('admin.tag.show', ['tag' => $tag]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Tag $tag)
{
return view('admin.tag.edit', ['tag' => $tag]);
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, Tag $tag)
{
$data = $request->validated();
$tag->update($data);

return view('admin.tag.show', ['tag' => $tag]);
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Tag $tag)
{
$tag->delete();

return redirect()->route('admin.tag.index');
}
}
78 changes: 78 additions & 0 deletions app/Http/Controllers/Admin/AdminUserController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\User\StoreRequest;
use App\Http\Requests\Admin\User\UpdateRequest;
use App\Jobs\StoreUserJob;
use App\Models\User;

class AdminUserController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$users = User::all();

return view('admin.user.index', ['users' => $users]);
}

/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.user.create');
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreRequest $request)
{
$data = $request->validated();
StoreUserJob::dispatch($data);

return redirect()->route('admin.user.index');
}

/**
* Display the specified resource.
*/
public function show(User $user)
{
return view('admin.user.show', ['user' => $user]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(User $user)
{
return view('admin.user.edit', ['user' => $user]);
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateRequest $request, User $user)
{
$data = $request->validated();
$user->update($data);

return view('admin.user.show', ['user' => $user]);
}

/**
* Remove the specified resource from storage.
*/
public function destroy(User $user)
{
$user->delete();

return redirect()->route('admin.user.index');
}
}
14 changes: 0 additions & 14 deletions app/Http/Controllers/Admin/Category/CreateController.php

This file was deleted.

16 changes: 0 additions & 16 deletions app/Http/Controllers/Admin/Category/DeleteController.php

This file was deleted.

15 changes: 0 additions & 15 deletions app/Http/Controllers/Admin/Category/EditController.php

This file was deleted.

17 changes: 0 additions & 17 deletions app/Http/Controllers/Admin/Category/IndexController.php

This file was deleted.

Loading