Сделана главная страница с инфой по стримам, инфа подтягивается из БД

This commit is contained in:
p.belezov 2024-01-31 12:05:03 +08:00
parent 11c038d492
commit 0ff8a2cf42
18 changed files with 305 additions and 8 deletions

View File

@ -6,7 +6,7 @@ namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
class IndexController extends Controller
class CaesarController extends Controller
{
public function index()
{

View File

@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Link;
class LinksController extends Controller
{
public function index(){
return $this->getAll();
}
public function getAll(){
$links = new Link();
return $links->all();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Weekdays;
use App\Models\Game;
use App\Models\Schedule;
use Illuminate\Support\Facades\DB;
class SchedulesController extends Controller
{
public function index(){
$finalSchedules = DB::table('schedules')
->join('weekdays', "schedules.weekday_id", "=", "weekdays.weekday_id")
->join("games", "schedules.game_id", "=", "games.game_id")
->select("weekdays.weekday_name", "weekdays.current_date", "games.name", "schedules.stream_time")
->get();
return $finalSchedules;
}
public function mmDate(){
$minmaxDates = DB::table("weekdays")
->select("weekdays.current_date")->where("weekday_id", "=", 1)
->orWhere("weekday_id", "=", 7)
->get();
return $minmaxDates;
}
}

11
app/Models/Game.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Game extends Model
{
use HasFactory;
}

11
app/Models/Link.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Link extends Model
{
use HasFactory;
}

11
app/Models/Schedule.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Schedule extends Model
{
use HasFactory;
}

11
app/Models/Weekdays.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Weekdays extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,29 @@
<?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('links', function (Blueprint $table) {
$table->id('link_id');
$table->text("link_name");
$table->text("link");
$table->text("image");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('links');
}
};

View File

@ -0,0 +1,28 @@
<?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('weekdays', function (Blueprint $table) {
$table->id("weekday_id");
$table->text("weekday_name");
$table->date("current_date");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('weekdays');
}
};

View File

@ -0,0 +1,27 @@
<?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('games', function (Blueprint $table) {
$table->id("game_id");
$table->text("name");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('games');
}
};

View File

@ -0,0 +1,33 @@
<?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('schedules', function (Blueprint $table) {
$table->id("schedule_id");
$table->foreignId("weekday_id")->constrained(
table: "weekdays", column: "weekday_id", indexName: "constraint_weekday_id"
);
$table->foreignId("game_id")->constrained(
table: "games", column: "game_id", indexName: "constraint_game_id"
);
$table->text("stream_time");
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('schedules');
}
};

View File

@ -3,7 +3,8 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
"build": "vite build",
"lara": "vite build && php artisan serve"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.3",

BIN
public/images/twitch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -0,0 +1,85 @@
<template>
<v-sheet class="bg-gradient h-100 w-100 d-flex justify-center">
<v-sheet class="mt-5 mb-5 rounded-lg w-75">
<p class="text-h3 ma-5">Расписание стримов</p>
<p class="ma-5 text-h4">{{ parseDate(dates[0].current_date) }} - {{ parseDate(dates[1].current_date) }}</p>
<div class="w-100 d-flex justify-center">
<v-table class="text-h5 w-66">
<tbody>
<tr v-for="schedule in schedules">
<td>{{ parseDate(schedule.current_date) }} {{ schedule.weekday_name }} {{ schedule.stream_time }}</td>
<td>{{ schedule.name }}</td>
</tr>
</tbody>
</v-table>
</div>
<p class="text-h3 ma-5">Ссылочки</p>
<div class="w-100 d-flex justify-center">
<v-list class="w-66">
<v-list-item class="ma-5" style="background-color: #1976D2; color: #FFFFFF" elevation="6" v-for="link in links" :href="link.link">
<template v-slot:prepend>
<v-avatar :image="link.image" rounded="0"></v-avatar>
</template>
<v-list-item-title>{{ link.link_name }}</v-list-item-title>
</v-list-item>
</v-list>
</div>
<!--
-->
</v-sheet>
</v-sheet>
</template>
<script>
import axios from "axios";
export default {
name: "Schedule",
data: () => ({
links: [],
schedules: [],
dates: []
}),
methods: {
parseDate(date){
let dateArr = date.split("-");
return dateArr[2] + "." + dateArr[1];
}
},
mounted() {
axios
.get('/api/v1/links')
.then(response => (this.links = response.data));
axios
.get('/api/v1/schedules')
.then(response => (this.schedules = response.data));
axios
.get('/api/v1/dates')
.then(response => (this.dates = response.data));
}
}
</script>
<style scoped>
.bg-gradient {
background: linear-gradient(-45deg, #f103b0, #f0a068, #4fdbfeff);
background-size: 200% 200%;
animation: gradient 15s ease infinite;
height: 100vh;
}
@keyframes gradient {
0% {
background-position: 0 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
</style>

View File

@ -1,15 +1,15 @@
<template>
<v-app>
<Polyfill></Polyfill>
<Schedule></Schedule>
</v-app>
</template>
<script>
import Polyfill from "./Polyfill.vue";
import Schedule from "./Schedule.vue"
export default {
name: "Welcome",
components: {Polyfill}
components: {Schedule}
}
</script>

View File

@ -112,7 +112,7 @@ export default {
<style scoped>
.bg-gradient {
background: linear-gradient(-45deg, #6947ea, #ffd298, #4698bb);
background: linear-gradient(-45deg, #f103b0, #f0a068, #4fdbfeff);
background-size: 200% 200%;
animation: gradient 15s ease infinite;
height: 100vh;

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Резюме</title>
<title>Информация о трансляциях</title>
@vite('resources/welcome.js')
@vite('resources/css/app.css')
</head>

View File

@ -14,4 +14,7 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::get('/', 'App\Http\Controllers\Api\V1\IndexController@index')->name('caesar');
Route::get('/', 'App\Http\Controllers\Api\V1\CaesarController@index')->name('caesar');
Route::get('/links', 'App\Http\Controllers\LinksController@index')->name('links');
Route::get('/schedules', 'App\Http\Controllers\SchedulesController@index')->name('schedules');
Route::get('/dates', 'App\Http\Controllers\SchedulesController@mmDate')->name('dates');