mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
135 lines
2.9 KiB
PHP
135 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Item;
|
|
use App\ItemCategory;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ItemCategoryController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('admin.itemcategory.index',['categories' => ItemCategory::all()]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('admin.itemcategory.add');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function store()
|
|
{
|
|
$c = new ItemCategory();
|
|
|
|
$c->name = \request('name');
|
|
$c->desc = \request('desc');
|
|
if (\request('is_training') == 1)
|
|
{
|
|
$c->is_training = 1;
|
|
}
|
|
else
|
|
{
|
|
$c->is_training = 0;
|
|
}
|
|
if (\request('is_op_appro') == 1)
|
|
{
|
|
$c->is_op_appro = 1;
|
|
}
|
|
else
|
|
{
|
|
$c->is_op_appro = 0;
|
|
}
|
|
|
|
$c->save();
|
|
|
|
return redirect('/admin/inventory/management/category/')->with('success','Catégorie ajouté avec succès');
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*
|
|
* @param \App\ItemCategory $itemCategory
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function show(ItemCategory $itemCategory)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param \App\ItemCategory $itemCategory
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
return view('admin.itemcategory.edit',['category' => ItemCategory::find($id)]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \App\ItemCategory $itemCategory
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update($id)
|
|
{
|
|
$c = ItemCategory::find($id);
|
|
|
|
$c->name = \request('name');
|
|
$c->desc = \request('desc');
|
|
if (\request('is_training') == 1)
|
|
{
|
|
$c->is_training = 1;
|
|
}
|
|
else
|
|
{
|
|
$c->is_training = 0;
|
|
}
|
|
if (\request('is_op_appro') == 1)
|
|
{
|
|
$c->is_op_appro = 1;
|
|
}
|
|
else
|
|
{
|
|
$c->is_op_appro = 0;
|
|
}
|
|
|
|
$c->save();
|
|
|
|
return redirect('/admin/inventory/management/category/')->with('success','Catégorie modifié avec succès');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*
|
|
* @param \App\ItemCategory $itemCategory
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$c = ItemCategory::find($id);
|
|
|
|
$c->delete();
|
|
}
|
|
}
|