Add Champion model, form validation, and components for StreamerPanel.

- Added Champion model to StreamerPanelController.
- Implemented form validation for champion_id, platform, username, and displayname in create and update methods.
- Created StreamerCreateForm and StreamersTable components for better organization.
This commit is contained in:
Rico van Zelst
2024-03-22 02:35:44 +01:00
parent c665d3f70f
commit b46128ec26
11 changed files with 212 additions and 12 deletions

View File

@@ -0,0 +1,50 @@
@push('top_scripts')
<script src="https://cdn.jsdelivr.net/npm/gridjs/dist/gridjs.umd.js"></script>
<link href="https://cdn.jsdelivr.net/npm/gridjs/dist/theme/mermaid.min.css" rel="stylesheet" />
@endpush
<div class="w-10/12 mx-auto">
<div id="streamers-wrapper"></div>
</div>
@push('bottom_scripts')
<script>
new gridjs.Grid({
columns: [
"Champion",
"Streamer Name",
{
name: "URL",
formatter: (_, row) => gridjs.html(
`<a href="${row.cells[2].data}" target="_blank">${row.cells[2].data}</a>`)
},
{
name: "Actions",
formatter: (_, row) => gridjs.html(row.cells[3].data)
}
],
data: [
@foreach ($streamers as $streamer)
["{{ $streamer->champion->name }}", "{{ $streamer->displayname }}",
"{{ $streamer->streamer_url }}", `<a href="/streamerpanel/edit/{{ $streamer->id }}">✏️</a> <a href="/streamerpanel/delete/{{ $streamer->id }}" onclick="event.preventDefault(); if (confirm('Are you sure you want to delete this streamer?')) { document.getElementById('delete-form-{{ $streamer->id }}').submit(); }"></a>
<form id="delete-form-{{ $streamer->id }}" action="/streamerpanel/delete/{{ $streamer->id }}" method="POST" style="display: none;">
@csrf
@method('DELETE')
</form>`
],
@endforeach
],
search: true,
pagination: {
limit: 20
},
language: {
'search': {
'placeholder': '🔍 Search streamers...'
}
}
}).render(document.getElementById("streamers-wrapper"));
</script>
@endpush