Files
UNIT3D/app/Http/Controllers/Staff/DonationGatewayController.php
Roardom 5f60ce6b77 refactor: enforce view filenames to use kebab case
Also had to use `@style` directives inside /resources/views/components/user-tag.blade.php. Prettier was erroring when the `@if` directive was inside the html attribute otherwise. Seems to have always been an issue, but the CI must only be formatting files that changed and because the file was only just changed now, it never discovered it until now.
2025-05-07 08:28:46 +00:00

96 lines
3.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Controllers\Staff;
use App\Http\Requests\Staff\StoreDonationGatewayRequest;
use App\Http\Requests\Staff\UpdateDonationGatewayRequest;
use Illuminate\Http\Request;
use App\Models\DonationGateway;
use App\Http\Controllers\Controller;
class DonationGatewayController extends Controller
{
/**
* Get All Donation Gateways.
*/
public function index(Request $request): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
abort_unless($request->user()->group->is_owner, 403);
return view('Staff.donation-gateway.index', ['gateways' => DonationGateway::orderBy('position')->paginate(25)]);
}
/**
* Create A Donation Gateway.
*/
public function create(Request $request): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
abort_unless($request->user()->group->is_owner, 403);
return view('Staff.donation-gateway.create');
}
/**
* Store A Donation Gateway.
*/
public function store(StoreDonationGatewayRequest $request)
{
abort_unless($request->user()->group->is_owner, 403);
DonationGateway::create($request->validated());
return redirect()->route('staff.gateways.index')
->with('success', 'Donation Gateway Added Successfully!');
}
/**
* Edit A Donation Gateway.
*/
public function edit(Request $request, DonationGateway $gateway): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
abort_unless($request->user()->group->is_owner, 403);
return view('Staff.donation-gateway.edit', ['gateway' => $gateway]);
}
/**
* Update A Donation Gateway.
*/
public function update(UpdateDonationGatewayRequest $request, DonationGateway $gateway): \Illuminate\Http\RedirectResponse
{
abort_unless($request->user()->group->is_owner, 403);
$gateway->update($request->validated());
return redirect()->route('staff.gateways.index')
->with('success', 'Donation Gateway Edited Successfully!');
}
/**
* Destroy A Donation Gateway.
*/
public function destroy(Request $request, DonationGateway $gateway)
{
abort_unless($request->user()->group->is_owner, 403);
$gateway->delete();
return redirect()->route('staff.gateways.index')
->with('success', 'Donation Gateway Deleted Successfully!');
}
}