⚝
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 :
CountryController.php
<?php namespace App\Http\Controllers; use App\Http\Requests\CreateCountryRequest; use App\Http\Requests\UpdateCountryRequest; use App\Models\Address; use App\Models\Country; use App\Models\Customer; use App\Models\Lead; use App\Repositories\CountryRepository; use Exception; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Http\Response; use Illuminate\View\View; class CountryController extends AppBaseController { /** @var CountryRepository */ private $countryRepo; public function __construct(CountryRepository $countryRepo) { $this->countryRepo = $countryRepo; } /** * Display a listing of the resource. * * @return Application|Factory|View */ public function index() { return view('countries.index'); } /** * Store a newly created resource in storage. * * @param CreateCountryRequest $request * @return Response */ public function store(CreateCountryRequest $request) { $input = $request->all(); $country = $this->countryRepo->create($input); activity()->performedOn($country)->causedBy(getLoggedInUser()) ->useLog('New Country created.')->log($country->name.' Country created.'); return $this->sendSuccess(__('messages.country.country_saved_successfully')); } /** * Show the form for editing the specified resource. * * @param Country $country * @return Response */ public function edit(Country $country) { return $this->sendResponse($country, 'Country retrieved successfully.'); } /** * Update the specified resource in storage. * * @param UpdateCountryRequest $request * @param Country $country * @return Response */ public function update(UpdateCountryRequest $request, Country $country) { $input = $request->all(); $country = $this->countryRepo->update($input, $country->id); activity()->performedOn($country)->causedBy(getLoggedInUser()) ->useLog('Country updated.')->log($country->name.' Country updated.'); return $this->sendSuccess(__('messages.country.country_updated_successfully')); } /** * Remove the specified resource from storage. * * @param Country $country * @return Response * * @throws Exception */ public function destroy(Country $country) { $customerCountry = Customer::whereCountry($country->id)->exists(); $leadCountry = Lead::whereCountry($country->id)->exists(); $addressCountry = Address::whereCountry($country->id)->exists(); if ($customerCountry || $leadCountry || $addressCountry) { return $this->sendError(__('messages.country.country_used_somewhere_else')); } $country = $country->delete(); return $this->sendSuccess('Country deleted successfully.'); } }