mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
92 lines
2.2 KiB
PHP
92 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Champion;
|
|
use App\Models\Streamer;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class StreamerPanelController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
return view('streamerpanel.index', [
|
|
'streamers' => Streamer::with('champion')->get(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
return view('streamerpanel.streamer-create', [
|
|
'champions' => Champion::all(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate(['champion_id' => 'required|exists:champions,champion_id',
|
|
'platform' => 'required|in:twitch,youtube,kick,douyu,huya',
|
|
'username' => 'required|string',
|
|
'displayname' => 'required|string',
|
|
]);
|
|
|
|
Streamer::create($request->all());
|
|
|
|
Cache::forget('streamersListAllAPICache');
|
|
|
|
return redirect()->route('streamerpanel.index');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Streamer $streamer)
|
|
{
|
|
return view('streamerpanel.streamer-edit', [
|
|
'streamer' => $streamer,
|
|
'champions' => Champion::all(),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, Streamer $streamer)
|
|
{
|
|
$request->validate([
|
|
'champion_id' => 'required|exists:champions,id',
|
|
'platform' => 'required|in:twitch,youtube,kick,douyu,huya',
|
|
'username' => 'required|string',
|
|
'displayname' => 'required|string',
|
|
]);
|
|
|
|
$streamer->update($request->all());
|
|
|
|
Cache::forget('streamersListAllAPICache');
|
|
|
|
return redirect()->route('streamerpanel.index');
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(Streamer $streamer)
|
|
{
|
|
$streamer->delete();
|
|
|
|
Cache::forget('streamersListAllAPICache');
|
|
|
|
return redirect()->route('streamerpanel.index');
|
|
}
|
|
}
|