mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 23:01:31 +00:00
79 lines
2.2 KiB
PHP
79 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\BasePageController;
|
|
use App\Models\Category;
|
|
use Illuminate\Http\Request;
|
|
|
|
class AdminCategoryController extends BasePageController
|
|
{
|
|
/**
|
|
* @throws \Exception
|
|
*/
|
|
public function index(): void
|
|
{
|
|
$this->setAdminPrefs();
|
|
$meta_title = $title = 'Category List';
|
|
|
|
$categorylist = Category::getFlat();
|
|
|
|
$this->smarty->assign('categorylist', $categorylist);
|
|
|
|
$content = $this->smarty->fetch('category-list.tpl');
|
|
|
|
$this->smarty->assign(compact('title', 'meta_title', 'content'));
|
|
$this->adminrender();
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Http\RedirectResponse|void
|
|
*
|
|
* @throws \Exception
|
|
*/
|
|
public function edit(Request $request)
|
|
{
|
|
$this->setAdminPrefs();
|
|
|
|
// set the current action
|
|
$action = $request->input('action') ?? 'view';
|
|
|
|
switch ($action) {
|
|
case 'submit':
|
|
Category::updateCategory(
|
|
$request->input('id'),
|
|
$request->input('status'),
|
|
$request->input('description'),
|
|
$request->input('disablepreview'),
|
|
$request->input('minsizetoformrelease'),
|
|
$request->input('maxsizetoformrelease')
|
|
);
|
|
|
|
return redirect()->to('admin/category-list');
|
|
break;
|
|
case 'view':
|
|
default:
|
|
if ($request->has('id')) {
|
|
$this->title = 'Category Edit';
|
|
$id = $request->input('id');
|
|
$cat = Category::find($id);
|
|
$this->smarty->assign('category', $cat);
|
|
}
|
|
break;
|
|
}
|
|
|
|
$this->smarty->assign('status_ids', [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE, Category::STATUS_DISABLED]);
|
|
$this->smarty->assign('status_names', ['Yes', 'No', 'Disabled']);
|
|
|
|
$content = $this->smarty->fetch('category-edit.tpl');
|
|
|
|
$this->smarty->assign(
|
|
[
|
|
'content' => $content,
|
|
'meta_title' => 'View/Edit categories',
|
|
]
|
|
);
|
|
$this->adminrender();
|
|
}
|
|
}
|