68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\WebService\Almoxarifado\Cliente;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Cadastro\Material\MaterialService as CadastroMaterialService;
|
|
use App\Services\WebService\Almoxarifado\Cliente\MaterialService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
|
|
class MaterialController extends Controller
|
|
{
|
|
protected $modulo = 'web-service';
|
|
protected $funcionalidade = 'almoxarifado-cliente-material';
|
|
|
|
public function create()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::create(), Response::HTTP_OK);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::store($request), Response::HTTP_CREATED);
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::edit($id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function update(Request $request, $id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(MaterialService::update($request, $id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
MaterialService::destroy($id);
|
|
|
|
return response()->noContent();
|
|
}
|
|
|
|
public function datatable()
|
|
{
|
|
return datatables()
|
|
->of(MaterialService::datatable())
|
|
->filterColumn('conectasus_material_descricao_completa', fn ($query, $keyword) => $query
|
|
->whereRaw(CadastroMaterialService::getDescricaoCompletaRaw(
|
|
'conectasus_material',
|
|
'conectasus_material_apresentacao',
|
|
'conectasus_material_apresentacao_unidade_medida'
|
|
) . " like ?", ["%{$keyword}%"])
|
|
)
|
|
->skipTotalRecords()
|
|
->toJson();
|
|
}
|
|
}
|