mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: code for emotes
This commit is contained in:
62
app/Http/Controllers/SummonerEmoteController.php
Normal file
62
app/Http/Controllers/SummonerEmoteController.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\SummonerEmote;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class SummonerEmoteController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$this->authorize('viewAny', SummonerEmote::class);
|
||||||
|
|
||||||
|
return SummonerEmote::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$this->authorize('create', SummonerEmote::class);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'emote_id' => ['required', 'integer'],
|
||||||
|
'title' => ['required'],
|
||||||
|
'description' => ['nullable'],
|
||||||
|
'image' => ['required'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return SummonerEmote::create($request->validated());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(SummonerEmote $summonerEmote)
|
||||||
|
{
|
||||||
|
$this->authorize('view', $summonerEmote);
|
||||||
|
|
||||||
|
return $summonerEmote;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, SummonerEmote $summonerEmote)
|
||||||
|
{
|
||||||
|
$this->authorize('update', $summonerEmote);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'emote_id' => ['required', 'integer'],
|
||||||
|
'title' => ['required'],
|
||||||
|
'description' => ['nullable'],
|
||||||
|
'image' => ['required'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$summonerEmote->update($request->validated());
|
||||||
|
|
||||||
|
return $summonerEmote;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(SummonerEmote $summonerEmote)
|
||||||
|
{
|
||||||
|
$this->authorize('delete', $summonerEmote);
|
||||||
|
|
||||||
|
$summonerEmote->delete();
|
||||||
|
|
||||||
|
return response()->json();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Models/SummonerEmote.php
Normal file
15
app/Models/SummonerEmote.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SummonerEmote extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'emote_id',
|
||||||
|
'title',
|
||||||
|
'description',
|
||||||
|
'image',
|
||||||
|
];
|
||||||
|
}
|
||||||
41
app/Policies/SummonerEmotePolicy.php
Normal file
41
app/Policies/SummonerEmotePolicy.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\SummonerEmote;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
|
||||||
|
class SummonerEmotePolicy
|
||||||
|
{
|
||||||
|
use HandlesAuthorization;
|
||||||
|
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(User $user, SummonerEmote $summonerEmote): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(User $user, SummonerEmote $summonerEmote): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(User $user, SummonerEmote $summonerEmote): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restore(User $user, SummonerEmote $summonerEmote): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forceDelete(User $user, SummonerEmote $summonerEmote): bool
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
// use Illuminate\Support\Facades\Gate;
|
// use Illuminate\Support\Facades\Gate;
|
||||||
|
use App\Models\SummonerEmote;
|
||||||
|
use App\Policies\SummonerEmotePolicy;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
@@ -14,6 +16,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
//
|
//
|
||||||
|
SummonerEmote::class => SummonerEmotePolicy::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('summoner_emotes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->integer('emote_id');
|
||||||
|
$table->string('title');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->string('image');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('summoner_emotes');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user