[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: TableController.php
<?php namespace App\Http\Controllers\Restaurant; use App\BusinessLocation; use App\Restaurant\ResTable; use Datatables; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Routing\Controller; class TableController extends Controller { /** * Display a listing of the resource. * * @return Response */ public function index() { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } if (request()->ajax()) { $business_id = request()->session()->get('user.business_id'); $tables = ResTable::where('res_tables.business_id', $business_id) ->join('business_locations AS BL', 'res_tables.location_id', '=', 'BL.id') ->select(['res_tables.name as name', 'BL.name as location', 'res_tables.description', 'res_tables.id', ]); return Datatables::of($tables) ->addColumn( 'action', '@role("Admin#'.$business_id.'") <button data-href="{{action(\'App\Http\Controllers\Restaurant\TableController@edit\', [$id])}}" class="tw-dw-btn tw-dw-btn-xs tw-dw-btn-outline tw-dw-btn-primary edit_table_button"><i class="glyphicon glyphicon-edit"></i> @lang("messages.edit")</button> @endrole @role("Admin#'.$business_id.'") <button data-href="{{action(\'App\Http\Controllers\Restaurant\TableController@destroy\', [$id])}}" class="tw-dw-btn tw-dw-btn-outline tw-dw-btn-xs tw-dw-btn-error delete_table_button"><i class="glyphicon glyphicon-trash"></i> @lang("messages.delete")</button> @endrole' ) ->removeColumn('id') ->escapeColumns(['action']) ->make(true); } return view('restaurant.table.index'); } /** * Show the form for creating a new resource. * * @return Response */ public function create() { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } $business_id = request()->session()->get('user.business_id'); $business_locations = BusinessLocation::forDropdown($business_id); return view('restaurant.table.create') ->with(compact('business_locations')); } /** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } try { $input = $request->only(['name', 'description', 'location_id']); $business_id = $request->session()->get('user.business_id'); $input['business_id'] = $business_id; $input['created_by'] = $request->session()->get('user.id'); $table = ResTable::create($input); $output = ['success' => true, 'data' => $table, '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 $output; } /** * Show the specified resource. * * @return Response */ public function show() { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } return view('restaurant.table.show'); } /** * Show the form for editing the specified resource. * * @return Response */ public function edit($id) { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } if (request()->ajax()) { $business_id = request()->session()->get('user.business_id'); $table = ResTable::where('business_id', $business_id)->find($id); return view('restaurant.table.edit') ->with(compact('table')); } } /** * Update the specified resource in storage. * * @param Request $request * @return Response */ public function update(Request $request, $id) { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } if (request()->ajax()) { try { $input = $request->only(['name', 'description']); $business_id = $request->session()->get('user.business_id'); $table = ResTable::where('business_id', $business_id)->findOrFail($id); $table->name = $input['name']; $table->description = $input['description']; $table->save(); $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 $output; } } /** * Remove the specified resource from storage. * * @return Response */ public function destroy($id) { if (! auth()->user()->can('access_tables')) { abort(403, 'Unauthorized action.'); } if (request()->ajax()) { try { $business_id = request()->user()->business_id; $table = ResTable::where('business_id', $business_id)->findOrFail($id); $table->delete(); $output = ['success' => true, 'msg' => __('lang_v1.deleted_success'), ]; } catch (\Exception $e) { \Log::emergency('File:'.$e->getFile().'Line:'.$e->getLine().'Message:'.$e->getMessage()); $output = ['success' => false, 'msg' => __('messages.something_went_wrong'), ]; } return $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.84 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