Add mnogo chego
This commit is contained in:
parent
36cb0c700a
commit
6fb18f6949
43
app/Console/Commands/AddAdmin.php
Normal file
43
app/Console/Commands/AddAdmin.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Admin;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AddAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:add-admin';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create new admin';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$admin = Admin::create();
|
||||
|
||||
$user = User::create([
|
||||
'email' => 'admin' . $admin->id . '@mail',
|
||||
'password' => 'password',
|
||||
]);
|
||||
|
||||
$admin->user()->save($user);
|
||||
|
||||
$this->info('Admin created successfully!');
|
||||
$this->info('email = ' . $user->email);
|
||||
$this->info('password = password');
|
||||
}
|
||||
}
|
@ -5,11 +5,20 @@ namespace App\Enums;
|
||||
enum ScoreEnum: string
|
||||
{
|
||||
case WithoutScore = 'Без оценки';
|
||||
case One = '1';
|
||||
case Two = '2';
|
||||
case Three = '3';
|
||||
case Four = '4';
|
||||
case Five = '5';
|
||||
case Absent = 'Н';
|
||||
case Sick = 'Б';
|
||||
|
||||
public static function getNumScores(): array
|
||||
{
|
||||
return [self::Two, self::Three, self::Four, self::Five];
|
||||
}
|
||||
|
||||
public static function getDebtScores(): array
|
||||
{
|
||||
return [self::Absent, self::Sick];
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Http\Requests\StudentPostRequest;
|
||||
use App\Models\Grade;
|
||||
use App\Models\Student;
|
||||
use App\Models\Subject;
|
||||
use App\Services\StudentService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
@ -119,10 +120,18 @@ class StudentController extends Controller
|
||||
return redirect()->route('students.index');
|
||||
}
|
||||
|
||||
public function scores(StudentService $service): View
|
||||
public function scores(StudentService $service, Subject $subject): View
|
||||
{
|
||||
return view('students.scores', [
|
||||
'scores' => $service->getScores(),
|
||||
'lessons' => $service->getScores($subject),
|
||||
'avgScore' => $service->getAvgScore($subject),
|
||||
]);
|
||||
}
|
||||
|
||||
public function debts(StudentService $service): View
|
||||
{
|
||||
return view('students.debts', [
|
||||
'lessons' => $service->getDebts(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,19 @@ namespace App\Http\Controllers;
|
||||
use App\Http\Requests\SubjectTeacherPostRequest;
|
||||
use App\Models\Subject;
|
||||
use App\Models\Teacher;
|
||||
use App\Services\TeacherService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SubjectTeacherController extends Controller
|
||||
{
|
||||
public function index(Teacher $teacher, TeacherService $service)
|
||||
{
|
||||
return view('subject-teacher.index', [
|
||||
'subjects' => $service->getSubjects($teacher),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(Teacher $teacher): View
|
||||
{
|
||||
return view('subject-teacher.create', [
|
||||
|
@ -18,14 +18,14 @@ class TeacherController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): View
|
||||
public function index(TeacherService $service): View
|
||||
{
|
||||
if(request()->user()->cannot('viewAny', Teacher::class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return view('teachers.index', [
|
||||
'teachers' => Teacher::filter()->paginate(5)->withQueryString(),
|
||||
'teachers' => $service->getTeachers(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
26
app/Http/Middleware/StudentAction.php
Normal file
26
app/Http/Middleware/StudentAction.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Student;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class StudentAction
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::user()->userable_type != Student::class) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ class TeacherPolicy
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->userable_type != Student::class;
|
||||
return $user->userable_type != Teacher::class;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,7 +22,7 @@ class TeacherPolicy
|
||||
*/
|
||||
public function view(User $user, Teacher $teacher): bool
|
||||
{
|
||||
return $user->userable_type == Teacher::class;
|
||||
return $user->userable_type == Admin::class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,6 @@ class FileService
|
||||
});
|
||||
});
|
||||
|
||||
return Pdf::loadView('subjects.pdf', ['subjects' => $listSubjects])->download('subjects.pdf');
|
||||
return Pdf::loadView('subjects.pdf', ['subjects' => $listSubjects])->download('Предметы.pdf');
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Enums\ScoreEnum;
|
||||
use App\Models\Student;
|
||||
use App\Models\Subject;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
@ -56,13 +57,29 @@ class StudentService
|
||||
$model->delete();
|
||||
}
|
||||
|
||||
public function getScores(): Collection
|
||||
public function getScores(Subject $subject): Collection
|
||||
{
|
||||
$student = Auth::user()->userable;
|
||||
foreach ($student->lessons as $lesson) {
|
||||
dd($lesson->pivot->score);
|
||||
}
|
||||
|
||||
return $student->lessons;
|
||||
return $student->lessons()->where('subject_id', $subject->id)->get();
|
||||
}
|
||||
|
||||
public function getAvgScore(Subject $subject)
|
||||
{
|
||||
$student = Auth::user()->userable;
|
||||
$scores = $student
|
||||
->lessons()
|
||||
->where('subject_id', $subject->id)
|
||||
->whereIn('score', ScoreEnum::getNumScores())
|
||||
->pluck('score');
|
||||
|
||||
return round($scores->avg(), 2);
|
||||
}
|
||||
|
||||
public function getDebts(): Collection
|
||||
{
|
||||
$student = Auth::user()->userable;
|
||||
|
||||
return $student->lessons()->whereIn('score', ScoreEnum::getDebtScores())->get();
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,7 @@ class SubjectService
|
||||
public function getSubjects()
|
||||
{
|
||||
if(Auth::user()->userable_type == Student::class) {
|
||||
$student = Auth::user()->userable;
|
||||
|
||||
return Subject::whereIn('id', $student->grade->subjects->pluck('id'))
|
||||
return Subject::whereIn('id', Auth::user()->userable->grade->subjects->pluck('id'))
|
||||
->filter()
|
||||
->paginate(5)
|
||||
->withQueryString();
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Student;
|
||||
use App\Models\Subject;
|
||||
use App\Models\Teacher;
|
||||
use App\Models\User;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TeacherService
|
||||
{
|
||||
@ -47,4 +50,30 @@ class TeacherService
|
||||
$teacher->user()->delete();
|
||||
$teacher->delete();
|
||||
}
|
||||
|
||||
public function getTeachers()
|
||||
{
|
||||
if (Auth::user()->userable_type == Student::class) {
|
||||
return Teacher::join('grade_teacher', 'teachers.id', '=', 'grade_teacher.teacher_id')
|
||||
->where('grade_id', Auth::user()->userable->grade_id)
|
||||
->filter()
|
||||
->paginate(5)
|
||||
->withQueryString();
|
||||
}
|
||||
|
||||
return Teacher::filter()->paginate(5)->withQueryString();
|
||||
}
|
||||
|
||||
public function getSubjects(Teacher $teacher)
|
||||
{
|
||||
if (Auth::user()->userable_type == Student::class) {
|
||||
return Subject::join('subject_teacher', 'subject_teacher.subject_id', '=', 'subjects.id')
|
||||
->join('grade_subject', 'grade_subject.subject_id', '=', 'subjects.id')
|
||||
->where('grade_subject.grade_id', Auth::user()->userable->grade_id)
|
||||
->where('subject_teacher.teacher_id', $teacher->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
return $teacher->subjects;
|
||||
}
|
||||
}
|
||||
|
50
config/tinker.php
Normal file
50
config/tinker.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to add additional Artisan commands that should
|
||||
| be available within the Tinker environment. Once the command is in
|
||||
| this array you may execute the command in Tinker using its name.
|
||||
|
|
||||
*/
|
||||
|
||||
'commands' => [
|
||||
App\Console\Commands\AddAdmin::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto Aliased Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Tinker will not automatically alias classes in your vendor namespaces
|
||||
| but you may explicitly allow a subset of classes to get aliased by
|
||||
| adding the names of each of those classes to the following list.
|
||||
|
|
||||
*/
|
||||
|
||||
'alias' => [
|
||||
//
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Classes That Should Not Be Aliased
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Typically, Tinker automatically aliases classes as you require them in
|
||||
| Tinker. However, you may wish to never alias certain classes, which
|
||||
| you may accomplish by listing the classes in the following array.
|
||||
|
|
||||
*/
|
||||
|
||||
'dont_alias' => [
|
||||
'App\Nova',
|
||||
],
|
||||
|
||||
];
|
@ -18,9 +18,39 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$namesSubjects = [
|
||||
'Русский язык',
|
||||
'Математика',
|
||||
'Английский язык',
|
||||
'Биология',
|
||||
'Химия',
|
||||
'Литература',
|
||||
'География',
|
||||
'История',
|
||||
'Обществознание',
|
||||
'Информатика',
|
||||
];
|
||||
$subjects = collect();
|
||||
|
||||
foreach ($namesSubjects as $name) {
|
||||
$subjects->push(Subject::factory()->create([
|
||||
'name' => $name,
|
||||
]));
|
||||
}
|
||||
|
||||
$letterGrades = ['A', 'Б', 'В',];
|
||||
$numberGrades = 11;
|
||||
$grades = collect();
|
||||
|
||||
while($numberGrades > 0) {
|
||||
foreach ($letterGrades as $letter) {
|
||||
$grades->push(Grade::factory()->create([
|
||||
'name' => $numberGrades . $letter,
|
||||
]));
|
||||
}
|
||||
$numberGrades--;
|
||||
}
|
||||
$teachers = Teacher::factory(15)->create();
|
||||
$grades = Grade::factory(10)->create();
|
||||
$subjects = Subject::factory(10)->create();
|
||||
$scores = ScoreEnum::cases();
|
||||
|
||||
$teachers->each(function ($teacher) {
|
||||
@ -28,33 +58,45 @@ class DatabaseSeeder extends Seeder
|
||||
$teacher->user()->save($user);
|
||||
});
|
||||
|
||||
$grades->each(function ($grade) use ($subjects, $teachers, $scores){
|
||||
$grade->subjects()->sync($subjects);
|
||||
$grade->teachers()->sync($teachers);
|
||||
$teacher = Teacher::factory()->create();
|
||||
$teacher->user()->save(User::factory()->create(['email' => 'teacher@mail']));
|
||||
$teacher->grades()->attach($grades->pluck('id'));
|
||||
|
||||
$students = Student::factory(10)->create([
|
||||
$student = Student::factory()->create(['grade_id' => $grades->first()->id]);
|
||||
$student->user()->save(User::factory()->create(['email' => 'student@mail']));
|
||||
|
||||
$grade = $student->grade;
|
||||
|
||||
$lessons = collect();
|
||||
$subjects->each(function ($item) use ($lessons, $teacher, $student, $grade) {
|
||||
$teacher->subjects()->attach($item);
|
||||
$grade->subjects()->attach($item);
|
||||
|
||||
$lessons->push(Lesson::factory(5)->create([
|
||||
'description' => 'Выполнение задания №3 на 87 стр. учебника',
|
||||
'grade_id' => $student->grade_id,
|
||||
'subject_id' => $item->id,
|
||||
'teacher_id' => $teacher->id,
|
||||
]));
|
||||
});
|
||||
|
||||
|
||||
$grades->each(function ($grade) use ($subjects, $teachers, $scores){
|
||||
Student::factory(30)->create([
|
||||
'grade_id' => $grade->id,
|
||||
])->each(function ($student) use ($scores) {
|
||||
$user = User::factory()->create();
|
||||
$student->user()->save($user);
|
||||
});
|
||||
|
||||
$lessons = Lesson::factory(30)->create([
|
||||
'grade_id' => $grade->id,
|
||||
'subject_id' => $grade->subjects->random()->id,
|
||||
'teacher_id' => $grade->teachers->random()->id,
|
||||
]);
|
||||
|
||||
$students->each(function ($student) use ($lessons, $scores) {
|
||||
$lessons->each(function ($lesson) use ($student, $scores) {
|
||||
$student->lessons()
|
||||
->syncWithoutDetaching([$lesson->id => ['score' => $scores[array_rand($scores)]]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$subjects->each(function ($subject) use ($teachers) {
|
||||
$subject->teachers()->sync($teachers->random(2));
|
||||
$grade->students->each(function ($student) use ($grade, $scores) {
|
||||
$grade->lessons->each(function ($lesson) use ($student, $scores) {
|
||||
$student->lessons()
|
||||
->syncWithoutDetaching([
|
||||
$lesson->id => ['score' => $scores[array_rand($scores)]]
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,12 @@
|
||||
<h5><strong>Описание: </strong>{{ $lesson->description }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('lessons.scores.show', $lesson) }}" class="btn btn-success">Оценки</a>
|
||||
<a href="{{ route('grades.lessons.edit', [$grade, $lesson]) }}" class="btn btn-primary">Редактировать</a>
|
||||
</div>
|
||||
@can('update', $lesson)
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('lessons.scores.show', $lesson) }}" class="btn btn-success">Оценки</a>
|
||||
<a href="{{ route('grades.lessons.edit', [$grade, $lesson]) }}" class="btn btn-primary">Редактировать</a>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,29 +11,43 @@
|
||||
</div>
|
||||
|
||||
<!-- Navigation Links -->
|
||||
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class)
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<x-nav-link :href="route('grades.index')" :active="request()->routeIs('dashboard')">
|
||||
<x-nav-link :href="route('grades.index')" :active="request()->routeIs('grades.index')">
|
||||
{{ __('Классы') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<x-nav-link :href="route('subjects.index')" :active="request()->routeIs('dashboard')">
|
||||
<x-nav-link :href="route('subjects.index')" :active="request()->routeIs('subjects.index')">
|
||||
{{ __('Предметы') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
|
||||
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Student::class)
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<x-nav-link :href="route('students.index')" :active="request()->routeIs('dashboard')">
|
||||
<x-nav-link :href="route('students.index')" :active="request()->routeIs('students.index')">
|
||||
{{ __('Студенты') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(\Illuminate\Support\Facades\Auth::user()->userable_type != \App\Models\Teacher::class)
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<x-nav-link :href="route('teachers.index')" :active="request()->routeIs('dashboard')">
|
||||
<x-nav-link :href="route('teachers.index')" :active="request()->routeIs('teachers.index')">
|
||||
{{ __('Учителя') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(\Illuminate\Support\Facades\Auth::user()->userable_type == \App\Models\Student::class)
|
||||
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
|
||||
<x-nav-link :href="route('student-debts')" :active="request()->routeIs('student-debts')">
|
||||
{{ __('Задолженности') }}
|
||||
</x-nav-link>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- Settings Dropdown -->
|
||||
@ -41,7 +55,7 @@
|
||||
<x-dropdown align="right" width="48">
|
||||
<x-slot name="trigger">
|
||||
<button class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-gray-500 bg-white hover:text-gray-700 focus:outline-none transition ease-in-out duration-150">
|
||||
<div>{{ Auth::user()->name }}</div>
|
||||
<div>{{ Auth::user()->userable->fio }}</div>
|
||||
|
||||
<div class="ms-1">
|
||||
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
|
28
resources/views/students/debts.blade.php
Normal file
28
resources/views/students/debts.blade.php
Normal file
@ -0,0 +1,28 @@
|
||||
@extends('layouts.application')
|
||||
|
||||
@section('content')
|
||||
<div class="container col-md-6">
|
||||
<div class="row justify-content-center">
|
||||
@if(count($lessons))
|
||||
@foreach($lessons as $lesson)
|
||||
<a href="{{ route('grades.lessons.show', [$lesson->grade_id, $lesson]) }}" class="text-decoration-none">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><strong>{{ $lesson->subject->name }} - {{ $lesson->pivot->score }}</strong></div>
|
||||
<div class="card-header">{{ $lesson->type }}</div>
|
||||
<div class="card-body">
|
||||
{{ $lesson->name }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><strong>Задолженности</strong></div>
|
||||
<div class="card-body">
|
||||
Задолженности отсутствуют
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
24
resources/views/students/scores.blade.php
Normal file
24
resources/views/students/scores.blade.php
Normal file
@ -0,0 +1,24 @@
|
||||
@extends('layouts.application')
|
||||
|
||||
@section('content')
|
||||
<div class="container col-md-6">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><strong>Средняя оценка - {{ $avgScore }}</strong></div>
|
||||
</div>
|
||||
@if(count($lessons))
|
||||
@foreach($lessons as $lesson)
|
||||
<a href="{{ route('grades.lessons.show', [$lesson->grade_id, $lesson]) }}" class="text-decoration-none">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><strong>{{ $lesson->subject->name }} - {{ $lesson->pivot->score }}</strong></div>
|
||||
<div class="card-header">{{ $lesson->type }}</div>
|
||||
<div class="card-body">
|
||||
{{ $lesson->name }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
19
resources/views/subject-teacher/index.blade.php
Normal file
19
resources/views/subject-teacher/index.blade.php
Normal file
@ -0,0 +1,19 @@
|
||||
@extends('layouts.application')
|
||||
|
||||
@section('content')
|
||||
<div class="container col-md-6">
|
||||
<div class="row justify-content-center">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">{{__('Предметы')}}</div>
|
||||
<div class="card-body">
|
||||
@if(count($subjects))
|
||||
<ul class="list-group list-group-flush text-center">
|
||||
@foreach ($subjects as $subject)
|
||||
<li class="list-group-item">{{ $subject->name }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -31,21 +31,30 @@
|
||||
<tr>
|
||||
<td class="table-text">
|
||||
<div>
|
||||
<a href="{{ route('subjects.show', $subject) }}" class="btn btn-block col-8">{{ $subject->name }}</a>
|
||||
{{ $subject->name }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('subjects.edit', $subject) }}" class="btn btn-warning">Редактировать</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<form action="{{ route('subjects.destroy', $subject) }}" method="POST" style="display: inline-block;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('student-scores', $subject) }}" class="btn btn-success">Оценки</a>
|
||||
</div>
|
||||
</td>
|
||||
@can('update', $subject)
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('subjects.edit', $subject) }}" class="btn btn-warning">Редактировать</a>
|
||||
</div>
|
||||
</td>
|
||||
@endcan
|
||||
@can('delete', $subject)
|
||||
<td>
|
||||
<form action="{{ route('subjects.destroy', $subject) }}" method="POST" style="display: inline-block;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
@endcan
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -55,7 +64,9 @@
|
||||
@endif
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('subjects.create') }}" class="btn btn-success">Добавить</a>
|
||||
@can('create', \App\Models\Subject::class)
|
||||
<a href="{{ route('subjects.create') }}" class="btn btn-success">Добавить</a>
|
||||
@endcan
|
||||
<a href="{{ route('export-pdf') }}" class="btn btn-info">PDF</a>
|
||||
</div>
|
||||
<div class="card-footer">{{ $subjects->links() }}</div>
|
||||
|
@ -31,21 +31,30 @@
|
||||
<tr>
|
||||
<td class="table-text">
|
||||
<div>
|
||||
<a href="{{ route('teachers.show', $teacher) }}" class="btn btn-block col-8">{{ $teacher->last_name }} {{ $teacher->name }} {{ $teacher->middle_name }}</a>
|
||||
{{ $teacher->fio }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('teachers.edit', $teacher) }}" class="btn btn-warning">Редактировать</a>
|
||||
<a href="{{ route('teachers.subjects.index', $teacher) }}" class="btn btn-warning">Предметы</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<form action="{{ route('teachers.destroy', $teacher) }}" method="POST" style="display: inline-block;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
@can('update', $teacher)
|
||||
<td>
|
||||
<div>
|
||||
<a href="{{ route('teachers.edit', $teacher) }}" class="btn btn-warning">Редактировать</a>
|
||||
</div>
|
||||
</td>
|
||||
@endcan
|
||||
@can('delete', $teacher)
|
||||
<td>
|
||||
<form action="{{ route('teachers.destroy', $teacher) }}" method="POST" style="display: inline-block;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</td>
|
||||
@endcan
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -54,9 +63,11 @@
|
||||
<p>Учителя отсутствуют</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('teachers.create') }}" class="btn btn-success">Добавить</a>
|
||||
</div>
|
||||
@can('create', Teacher::class)
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('teachers.create') }}" class="btn btn-success">Добавить</a>
|
||||
</div>
|
||||
@endcan
|
||||
<div class="card-footer">{{ $teachers->links() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Middleware\AdminAction;
|
||||
use App\Http\Middleware\StudentAction;
|
||||
use App\Http\Middleware\TeacherAction;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\GradeController;
|
||||
@ -47,9 +48,12 @@ Route::middleware('auth')->group(function () {
|
||||
Route::get('grades/{grade}/subjects/{subject}/journal', [GradeSubjectController::class, 'journal'])->name('grades.subjects.journal');
|
||||
});
|
||||
|
||||
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
|
||||
|
||||
Route::get('student-scores', [StudentController::class, 'scores'])->name('student-scores');
|
||||
Route::middleware([StudentAction::class])->group(function () {
|
||||
Route::get('export-pdf', [SubjectController::class, 'exportToPDF'])->name('export-pdf');
|
||||
Route::get('subjects/{subject}/student-scores', [StudentController::class, 'scores'])->name('student-scores');
|
||||
Route::get('student-debts', [StudentController::class, 'debts'])->name('student-debts');
|
||||
Route::get('teachers/{teacher}/subjects', [SubjectTeacherController::class, 'index'])->name('teachers.subjects.index');
|
||||
});
|
||||
});
|
||||
|
||||
require __DIR__.'/auth.php';
|
||||
|
Loading…
Reference in New Issue
Block a user