⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.94
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
/
hrms.dev-unit.com
/
app
/
Http
/
Controllers
/
View File Name :
OtherPaymentController.php
<?php namespace App\Http\Controllers; use App\Models\Employee; use App\Models\OtherPayment; use Illuminate\Http\Request; class OtherPaymentController extends Controller { public function otherpaymentCreate($id) { $employee = Employee::find($id); $otherpaytype=OtherPayment::$otherPaymenttype; return view('otherpayment.create', compact('employee','otherpaytype')); } public function store(Request $request) { if(\Auth::user()->can('Create Other Payment')) { $validator = \Validator::make( $request->all(), [ 'employee_id' => 'required', 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $otherpayment = new OtherPayment(); $otherpayment->employee_id = $request->employee_id; $otherpayment->title = $request->title; $otherpayment->type = $request->type; $otherpayment->amount = $request->amount; $otherpayment->created_by = \Auth::user()->creatorId(); $otherpayment->save(); if( $otherpayment->type == 'percentage' ) { $employee = Employee::find($otherpayment->employee_id); $loansal = $otherpayment->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('OtherPayment successfully created.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show(OtherPayment $otherpayment) { return redirect()->route('commision.index'); } public function edit($otherpayment) { $otherpayment = OtherPayment::find($otherpayment); if(\Auth::user()->can('Edit Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $otherpaytypes=OtherPayment::$otherPaymenttype; return view('otherpayment.edit', compact('otherpayment','otherpaytypes')); } else { return response()->json(['error' => __('Permission denied.')], 401); } } else { return response()->json(['error' => __('Permission denied.')], 401); } } public function update(Request $request, OtherPayment $otherpayment) { if(\Auth::user()->can('Edit Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $validator = \Validator::make( $request->all(), [ 'title' => 'required', 'amount' => 'required', ] ); if($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $otherpayment->title = $request->title; $otherpayment->type = $request->type; $otherpayment->amount = $request->amount; $otherpayment->save(); if( $otherpayment->type == 'percentage' ) { $employee = Employee::find($otherpayment->employee_id); $loansal = $otherpayment->amount * $employee->salary / 100; } return redirect()->back()->with('success', __('OtherPayment successfully updated.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function destroy(OtherPayment $otherpayment) { if(\Auth::user()->can('Delete Other Payment')) { if($otherpayment->created_by == \Auth::user()->creatorId()) { $otherpayment->delete(); return redirect()->back()->with('success', __('OtherPayment successfully deleted.')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } }