mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: Add Streamer and StreamerPanel controllers, Streamer model
- Added StreamerController with index and show methods - Added StreamerPanelController with index, create, store, edit, update, and destroy methods - Created Streamer model with fillable attributes and platform-specific URL generation logic - Implemented migration for creating the streamers table
This commit is contained in:
25
app/Http/Controllers/StreamerController.php
Normal file
25
app/Http/Controllers/StreamerController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Streamer;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StreamerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Streamer $streamer)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
57
app/Http/Controllers/StreamerPanelController.php
Normal file
57
app/Http/Controllers/StreamerPanelController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Streamer;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StreamerPanelController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Streamer $streamer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Streamer $streamer)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Streamer $streamer)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
42
app/Models/Streamer.php
Normal file
42
app/Models/Streamer.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Streamer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['champion_id', 'platform', 'username', 'displayname'];
|
||||
|
||||
public function champion()
|
||||
{
|
||||
return $this->belongsTo(Champion::class);
|
||||
}
|
||||
|
||||
public function getPlatformAttribute($value): string
|
||||
{
|
||||
$platforms = [
|
||||
'twitch' => 'Twitch',
|
||||
'youtube' => 'YouTube',
|
||||
'kick' => 'Kick',
|
||||
'douyu' => 'Douyu',
|
||||
'huya' => 'Huya',
|
||||
];
|
||||
|
||||
return $platforms[$value];
|
||||
}
|
||||
|
||||
public function getStreamerUrlAttribute(): string
|
||||
{
|
||||
return match ($this->platform) {
|
||||
'Twitch' => "https://www.twitch.tv/{$this->username}",
|
||||
'YouTube' => "https://www.youtube.com/@{$this->username}",
|
||||
'Kick' => "https://kick.com/{$this->username}",
|
||||
'Douyu' => "https://www.douyu.com/{$this->username}",
|
||||
'Huya' => "https://www.huya.com/{$this->username}",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('streamers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('champion_id')->constrained();
|
||||
$table->enum('platform', ['twitch', 'youtube', 'kick', 'douyu', 'huya']);
|
||||
$table->string('username');
|
||||
$table->string('displayname');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('streamers');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user