mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-23 19:50:40 -05:00
update: combine staff wiki and wiki category pages
This commit is contained in:
@@ -26,7 +26,10 @@ class WikiCategoryController extends Controller
|
||||
public function index(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('Staff.wiki_category.index', [
|
||||
'wikiCategories' => WikiCategory::orderBy('position')->get(),
|
||||
'wikiCategories' => WikiCategory::query()
|
||||
->with(['wikis' => fn ($query) => $query->orderBy('name')])
|
||||
->orderBy('position')
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,25 +18,17 @@ use App\Http\Requests\Staff\StoreWikiRequest;
|
||||
use App\Http\Requests\Staff\UpdateWikiRequest;
|
||||
use App\Models\Wiki;
|
||||
use App\Models\WikiCategory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WikiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display All Pages.
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('Staff.wiki.index', [
|
||||
'wikis' => Wiki::with(['category'])->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Page Add Form.
|
||||
*/
|
||||
public function create(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
|
||||
public function create(Request $request): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('Staff.wiki.create', [
|
||||
'wikiCategoryId' => $request->integer('wikiCategoryId'),
|
||||
'wikiCategories' => WikiCategory::query()->orderBy('position')->get(),
|
||||
]);
|
||||
}
|
||||
@@ -48,7 +40,7 @@ class WikiController extends Controller
|
||||
{
|
||||
Wiki::create($request->validated());
|
||||
|
||||
return to_route('staff.wikis.index')
|
||||
return to_route('staff.wiki_categories.index')
|
||||
->withSuccess('Wiki has been created successfully');
|
||||
}
|
||||
|
||||
@@ -70,7 +62,7 @@ class WikiController extends Controller
|
||||
{
|
||||
$wiki->update($request->validated());
|
||||
|
||||
return to_route('staff.wikis.index')
|
||||
return to_route('staff.wiki_categories.index')
|
||||
->withSuccess('Wiki has been edited successfully');
|
||||
}
|
||||
|
||||
@@ -81,7 +73,7 @@ class WikiController extends Controller
|
||||
{
|
||||
$wiki->delete();
|
||||
|
||||
return to_route('staff.wikis.index')
|
||||
return to_route('staff.wiki_categories.index')
|
||||
->withSuccess('Wiki has been deleted successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,15 +190,6 @@
|
||||
<a
|
||||
class="form__button form__button--text"
|
||||
href="{{ route('staff.wiki_categories.index') }}"
|
||||
>
|
||||
<i class="fab fa-wikipedia-w"></i>
|
||||
Wiki Categories
|
||||
</a>
|
||||
</p>
|
||||
<p class="form__group form__group--horizontal">
|
||||
<a
|
||||
class="form__button form__button--text"
|
||||
href="{{ route('staff.wikis.index') }}"
|
||||
>
|
||||
<i class="fab fa-wikipedia-w"></i>
|
||||
Wikis
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumbV2">
|
||||
<a href="{{ route('staff.wikis.index') }}" class="breadcrumb__link">Wikis</a>
|
||||
<a href="{{ route('staff.wiki_categories.index') }}" class="breadcrumb__link">Wikis</a>
|
||||
</li>
|
||||
<li class="breadcrumb--active">
|
||||
{{ __('common.new-adj') }}
|
||||
@@ -32,9 +32,21 @@
|
||||
</label>
|
||||
</p>
|
||||
<p class="form__group">
|
||||
<select id="category_id" name="category_id" class="form__select">
|
||||
<select
|
||||
id="category_id"
|
||||
name="category_id"
|
||||
class="form__select"
|
||||
x-data="{ selected: {{ $wikiCategoryId }} || '' }"
|
||||
x-model="selected"
|
||||
x-bind:class="selected === '' ? 'form__selected--default' : ''"
|
||||
required
|
||||
>
|
||||
<option disabled hidden></option>
|
||||
@foreach ($wikiCategories as $wikiCategory)
|
||||
<option value="{{ $wikiCategory->id }}">
|
||||
<option
|
||||
value="{{ $wikiCategory->id }}"
|
||||
@selected($wikiCategory->id === $wikiCategoryId)
|
||||
>
|
||||
{{ $wikiCategory->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="breadcrumbV2">
|
||||
<a href="{{ route('staff.wikis.index') }}" class="breadcrumb__link">Wikis</a>
|
||||
<a href="{{ route('staff.wiki_categories.index') }}" class="breadcrumb__link">Wikis</a>
|
||||
</li>
|
||||
<li class="breadcrumbV2">
|
||||
{{ $wiki->name }}
|
||||
|
||||
@@ -9,80 +9,128 @@
|
||||
<li class="breadcrumb--active">Wiki Categories</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<section class="panelV2">
|
||||
<header class="panel__header">
|
||||
<h2 class="panel__heading">Wiki Categories</h2>
|
||||
<div class="panel__actions">
|
||||
<a
|
||||
href="{{ route('staff.wiki_categories.create') }}"
|
||||
class="panel__action form__button form__button--text"
|
||||
>
|
||||
{{ __('common.add') }}
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="data-table-wrapper">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('common.title') }}</th>
|
||||
<th>{{ __('common.position') }}</th>
|
||||
<th>{{ __('common.icon') }}</th>
|
||||
<th>{{ __('common.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($wikiCategories as $wikiCategory)
|
||||
@section('main')
|
||||
@foreach ($wikiCategories as $category)
|
||||
<section class="panelV2">
|
||||
<header class="panel__header">
|
||||
<h2 class="panel__heading">{{ $category->name }}</h2>
|
||||
<div class="panel__actions">
|
||||
<div class="panel__action">
|
||||
<a
|
||||
href="{{ route('staff.wikis.create', ['wikiCategoryId' => $category->id]) }}"
|
||||
class="form__button form__button--text"
|
||||
>
|
||||
{{ __('common.add') }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="panel__action">
|
||||
<a
|
||||
href="{{ route('staff.wiki_categories.edit', ['wikiCategory' => $category]) }}"
|
||||
class="form__button form__button--text"
|
||||
>
|
||||
{{ __('common.edit') }}
|
||||
</a>
|
||||
</div>
|
||||
<form
|
||||
action="{{ route('staff.wiki_categories.destroy', ['wikiCategory' => $category]) }}"
|
||||
method="POST"
|
||||
style="display: contents"
|
||||
x-data="confirmation"
|
||||
>
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button
|
||||
class="form__button form__button--text"
|
||||
x-on:click.prevent="confirmAction"
|
||||
data-b64-deletion-message="{{ base64_encode('Are you sure you want to delete this wiki category (' . $category->name . ') and all wikis within?') }}"
|
||||
>
|
||||
{{ __('common.delete') }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</header>
|
||||
<div class="data-table-wrapper">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<a
|
||||
href="{{ route('staff.wiki_categories.edit', ['wikiCategory' => $wikiCategory]) }}"
|
||||
>
|
||||
{{ $wikiCategory->name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $wikiCategory->position }}</td>
|
||||
<td>
|
||||
<i class="{{ $wikiCategory->icon }}" aria-hidden="true"></i>
|
||||
</td>
|
||||
<td>
|
||||
<menu class="data-table__actions">
|
||||
<li class="data-table__action">
|
||||
<a
|
||||
href="{{ route('staff.wiki_categories.edit', ['wikiCategory' => $wikiCategory]) }}"
|
||||
class="form__button form__button--text"
|
||||
>
|
||||
{{ __('common.edit') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="data-table__action">
|
||||
<form
|
||||
action="{{ route('staff.wiki_categories.destroy', ['wikiCategory' => $wikiCategory]) }}"
|
||||
method="POST"
|
||||
x-data="confirmation"
|
||||
>
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button
|
||||
x-on:click.prevent="confirmAction"
|
||||
data-b64-deletion-message="{{ base64_encode('Are you sure you want to delete this wiki category: ' . $wikiCategory->name . '?') }}"
|
||||
<th>{{ __('common.name') }}</th>
|
||||
<th>{{ __('common.created_at') }}</th>
|
||||
<th>{{ __('torrent.updated_at') }}</th>
|
||||
<th>{{ __('common.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($category->wikis as $wiki)
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{ route('wikis.show', ['wiki' => $wiki]) }}">
|
||||
{{ $wiki->name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $wiki->created_at }}</td>
|
||||
<td>{{ $wiki->updated_at }}</td>
|
||||
<td>
|
||||
<menu class="data-table__actions">
|
||||
<li class="data-table__action">
|
||||
<a
|
||||
href="{{ route('staff.wikis.edit', ['wiki' => $wiki]) }}"
|
||||
class="form__button form__button--text"
|
||||
>
|
||||
{{ __('common.delete') }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
</menu>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="2">No Wiki Categories</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
{{ __('common.edit') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="data-table__action">
|
||||
<form
|
||||
action="{{ route('staff.wikis.destroy', ['wiki' => $wiki]) }}"
|
||||
method="POST"
|
||||
x-data="confirmation"
|
||||
>
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button
|
||||
x-on:click.prevent="confirmAction"
|
||||
data-b64-deletion-message="{{ base64_encode('Are you sure you want to delete this wiki: ' . $wiki->name . '?') }}"
|
||||
class="form__button form__button--text"
|
||||
>
|
||||
{{ __('common.delete') }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
</menu>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="4">No Wikis</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
@endforeach
|
||||
@endsection
|
||||
|
||||
@section('sidebar')
|
||||
<section class="panelV2">
|
||||
<h2 class="panel__heading">{{ __('common.actions') }}</h2>
|
||||
<div class="panel__body">
|
||||
<p class="form__group form__group--horizontal">
|
||||
<a
|
||||
href="{{ route('staff.wiki_categories.create') }}"
|
||||
class="form__button form__button--filled form__button--centered"
|
||||
>
|
||||
Create new category
|
||||
</a>
|
||||
</p>
|
||||
<p class="form__group form__group--horizontal">
|
||||
<a
|
||||
href="{{ route('staff.wikis.create') }}"
|
||||
class="form__button form__button--filled form__button--centered"
|
||||
>
|
||||
Create new wiki
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user