add timetable to User dashboard
Tests & Lint & Deploy to Railway / build (2.6.6, 20.x, 8.3) (push) Failing after 53s Details
Tests & Lint & Deploy to Railway / deploy (push) Has been skipped Details

This commit is contained in:
aslan 2024-07-12 12:47:16 +03:00
parent 9d2ba99c1d
commit 2d9ca7a95c
5 changed files with 186 additions and 28 deletions

20
app/Helpers/GetDay.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Helpers;
class GetDay
{
public static function getDay($day): string
{
$daysMap = [
1 => 'Понедельник',
2 => 'Вторник',
3 => 'Среда',
4 => 'Четверг',
5 => 'Пятница',
6 => 'Суббота',
7 => 'Воскресение',
];
return array_key_exists($day, $daysMap) ? $daysMap[$day] : 'День недели не определен!';
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Services;
use PDO;
use PHPStan\Cache\Cache;
class GetInfoOfStudent
{
private $connect;
public function __construct($connection)
{
$this->connect = $connection;
}
public function getInfo($user): array
{
return $this->connect->getInfo($user);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Services;
class TestConnect
{
public function getInfo($user): array
{
return [
'guid' => '3897263a-208f-11ee-93a9-f8cc6e370457',
'guid_faculty' => '4cbc06bd-5f3d-11ec-80b4-a0369f032517',
'guid_group' => '662e64d7-b4ad-11ec-937c-f8cc6e370458',
'name' => 'Абдулазиева Мадина Ибрагимовна',
'first_name' => 'Мадина1',
'last_name' => 'Абдулазиева',
'middle_name' => 'Ибрагимовна',
'number_record_book' => '23009202',
'email' => 'test@example.com',
'faculty' => 'Лечебный факультет',
'course' => 'Первый',
'group' => 'ЛД-103',
'code' => '31.05.01',
'form_education' => 'Очная',
];
}
}

View File

@ -1,47 +1,141 @@
@php
use App\Helpers\GetDay;
use Carbon\Carbon;
$dayNumber = 1;
@endphp
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('Dashboard') }}
Текущая неделя:
@if($currentWeek['err'] !== 0)
Что то сломалось: {{ $currentWeek['msg'] }}
@elseif($currentWeek['week_cur'] == 1)
нечетная
@else
четная
@endif
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900 dark:text-gray-100">
{{ __("You're logged in!") }}
@if($timetable['err'] !== 0)
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-gray-900 dark:text-gray-100">
{{ $timetable['msg'] }}
</div>
</div>
</div>
</div>
</div>
@else
<div class="container">
<div class="row align-items-start">
<div class="col">
<div class="accordion max-w-7xl mx-auto sm:px-6 lg:px-8" id="accordionPanelsStayOpenExample">
@foreach($timetable[$currentWeek['week_cur']] as $day => $subjects)
<div class="accordion-item">
<h2 class="accordion-header">
<button
class="accordion-button @if(Carbon::now()->dayOfWeek !== $dayNumber) collapsed @endif"
type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapse{{ $dayNumber }}" aria-expanded="true"
aria-controls="panelsStayOpen-collapse{{ $dayNumber }}">
{{ GetDay::getDay($day) }}
</button>
</h2>
<div id="panelsStayOpen-collapse{{ $dayNumber }}"
class="accordion-collapse collapse @if(Carbon::now()->dayOfWeek === $dayNumber) show @endif">
<div class="accordion-body">
@foreach($subjects as $subject)
{{ $subject['time1'] }} ({{ $subject['time_name'][0] }} - {{ $subject['time_name'][1] }}) / <strong>{{ $subject['predmet'] }} </strong> ({{ $subject['vid_name'] }})<br>
Аудитория: {{ $subject['aname'] }} <br>
Преподаватель: {{ $subject['fio'] }} <br>
<br>
@endforeach
</div>
</div>
</div>
@php $dayNumber++ @endphp
@endforeach
</div>
</div>
<div class="col">
<div class="accordion max-w-7xl mx-auto sm:px-6 lg:px-8" id="accordionPanelsStayOpenExample">
<div class="accordion-item text-center">Следующая неделя</div>
@foreach($timetable[($currentWeek['week_cur'] === 1) ? 2 : 1] as $day => $subjects)
<div class="accordion-item">
<h2 class="accordion-header">
<button
class="accordion-button collapsed"
type="button" data-bs-toggle="collapse"
data-bs-target="#panelsStayOpen-collapse{{ $dayNumber }}" aria-expanded="true"
aria-controls="panelsStayOpen-collapse{{ $dayNumber }}">
{{ GetDay::getDay($day) }}
</button>
</h2>
<div id="panelsStayOpen-collapse{{ $dayNumber }}"
class="accordion-collapse collapse">
<div class="accordion-body">
@foreach($subjects as $subject)
{{ $subject['time1'] }} ({{ $subject['time_name'][0] }} - {{ $subject['time_name'][1] }}) / <strong>{{ $subject['predmet'] }} </strong> ({{ $subject['vid_name'] }})<br>
Аудитория: {{ $subject['aname'] }} <br>
Преподаватель: {{ $subject['fio'] }} <br>
<br>
@endforeach
</div>
</div>
</div>
@php $dayNumber++ @endphp
@endforeach
</div>
</div>
</div>
</div>
@endif
<div class="container">
<div class="container py-12 max-w-7xl mx-auto sm:px-6 lg:px-8">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
<th colspan="2">Профиль</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Полное имя</td>
<td>{{ $user->name }}</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
<td>Email</td>
<td>{{ $user->email }}</td>
</tr>
<tr>
<th scope="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
<td>Имя</td>
<td>{{ $user->first_name }}</td>
</tr>
<tr>
<td>Фамилия</td>
<td>{{ $user->last_name }}</td>
</tr>
<tr>
<td>Отчество</td>
<td>{{ $user->middle_name }}</td>
</tr>
<tr>
<td>Зачетная книжка</td>
<td>{{ $user->number_record_book }}</td>
</tr>
<tr>
<td>Факультет</td>
<td>{{ $user->faculty }}</td>
</tr>
<tr>
<td>Курс</td>
<td>{{ $user->course }}</td>
</tr>
<tr>
<td>Группа</td>
<td>{{ $user->group }}</td>
</tr>
</tbody>
</table>

View File

@ -7,11 +7,8 @@ Route::get('/', function () {
return view('welcome');
});
Route::get('/dashboard', function () {
return view('dashboard');
})->middleware(['auth', 'verified'])->name('dashboard');
Route::middleware('auth')->group(function () {
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/dashboard', [ProfileController::class, 'show'])->name('dashboard');
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');