⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
crm.dev-unit.com
/
app
/
Http
/
Controllers
/
View File Name :
ContractTypeController.php
<?php namespace App\Http\Controllers; use App\Http\Requests\CreateContractTypeRequest; use App\Http\Requests\UpdateContractTypeRequest; use App\Models\Contract; use App\Models\ContractType; use App\Queries\ContractTypeDataTable; use App\Repositories\ContractTypeRepository; use Exception; use Illuminate\Contracts\View\Factory; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\View\View; use Yajra\DataTables\DataTables; class ContractTypeController extends AppBaseController { /** @var ContractTypeRepository */ private $contractTypeRepository; public function __construct(ContractTypeRepository $contractTypeRepo) { $this->contractTypeRepository = $contractTypeRepo; } /** * Display a listing of the ContractType. * * @param Request $request * @return Factory|View * * @throws Exception */ public function index(Request $request) { if ($request->ajax()) { return DataTables::of((new ContractTypeDataTable())->get())->make(); } return view('contract_types.index'); } /** * Store a newly created ContractType in storage. * * @param CreateContractTypeRequest $request * @return JsonResponse */ public function store(CreateContractTypeRequest $request) { $input = $request->all(); $contractType = $this->contractTypeRepository->create($input); activity()->performedOn($contractType)->causedBy(getLoggedInUser()) ->useLog('New Contract Type created.')->log($contractType->name.' Contract Type created.'); return $this->sendResponse($contractType, __('messages.contract_type.contract_type_saved_successfully')); } /** * Show the form for editing the specified ContractType. * * @param ContractType $contractType * @return JsonResponse */ public function edit(ContractType $contractType) { return $this->sendResponse($contractType, 'Contract Type retrieved successfully.'); } /** * Update the specified ContractType in storage. * * @param ContractType $contractType * @param UpdateContractTypeRequest $request * @return JsonResponse */ public function update(ContractType $contractType, UpdateContractTypeRequest $request) { $input = $request->all(); $contractType = $this->contractTypeRepository->update($input, $contractType->id); activity()->performedOn($contractType)->causedBy(getLoggedInUser()) ->useLog('Contract Type updated.')->log($contractType->name.' Contract Type updated.'); return $this->sendSuccess(__('messages.contract_type.contract_type_updated_successfully')); } /** * Remove the specified ContractType from storage. * * @param ContractType $contractType * @return JsonResponse */ public function destroy(ContractType $contractType) { $contractTypeId = Contract::where('contract_type_id', '=', $contractType->id)->exists(); if ($contractTypeId) { return $this->sendError(__('messages.contract_type.contract_type_used_somewhere_else')); } activity()->performedOn($contractType)->causedBy(getLoggedInUser()) ->useLog('Contract Type deleted.')->log($contractType->name.' Contract Type deleted.'); $contractType->delete(); return $this->sendSuccess('Contract Type deleted successfully.'); } }