74 lines
1.4 KiB
PHP
74 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
/**
|
|
* @copyright Copyright (c) 2023 Notsoweb (https://notsoweb.com) - All rights reserved.
|
|
*/
|
|
|
|
use App\Http\Requests\StoreDepartment;
|
|
use App\Http\Requests\UpdateDepartment;
|
|
use App\Models\department;
|
|
use Notsoweb\Core\Http\Controllers\VueController;
|
|
|
|
/**
|
|
* Descripción
|
|
*
|
|
* @author Moisés de Jesús Cortés Castellanos <ing.moisesdejesuscortesc@notsoweb.com>
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
class DepartmentController extends VueController
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
$this->vueRoot('admin.departments');
|
|
}
|
|
|
|
|
|
public function index()
|
|
{
|
|
$q = request()->get('q');
|
|
|
|
return $this->vuew('index', [
|
|
'departments' => department::where('name', 'LIKE', "%{$q}%")
|
|
->orWhere('description', 'LIKE', "%{$q}%")
|
|
->select([
|
|
'id',
|
|
'name',
|
|
'description',
|
|
])
|
|
->paginate(config('app.pagination'))
|
|
]);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return $this->vuew('create');
|
|
}
|
|
|
|
public function store(StoreDepartment $request)
|
|
{
|
|
$data = $request->all();
|
|
|
|
department::create($data);
|
|
|
|
return $this->index();
|
|
}
|
|
|
|
public function update(UpdateDepartment $request, $department)
|
|
{
|
|
$data = $request->all();
|
|
|
|
department::find($department)->update($data);
|
|
}
|
|
|
|
public function destroy($department)
|
|
{
|
|
department::find($department)->delete();
|
|
|
|
return $this->index();
|
|
}
|
|
}
|