refactoring Departments and Directions

This commit is contained in:
aslan 2024-02-12 11:25:00 +03:00
parent 07cb065e1c
commit 54765f6202
4 changed files with 48 additions and 47 deletions

View File

@ -4,10 +4,10 @@ namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreDirectionRequest; use App\Http\Requests\admin\Catalog\StoreDirectionRequest;
use App\Http\Requests\admin\Catalog\UpdateDepartmentRequest;
use App\Http\Requests\admin\Catalog\UpdateDirectionRequest; use App\Http\Requests\admin\Catalog\UpdateDirectionRequest;
use App\Models\Department; use App\Models\Department;
use App\Models\Direction; use App\Models\Direction;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
@ -44,7 +44,18 @@ class DirectionController extends Controller
public function show(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application public function show(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{ {
return view('admin.catalog.direction.show', compact('direction')); $department = $direction->department;
$faculty = Faculty::find($department->faculty->id);
$educationalInstitution = $faculty->educationalInstitution;
return view(
'admin.catalog.direction.show',
compact(
'direction',
'educationalInstitution',
'faculty',
'department',
)
);
} }
public function edit(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application public function edit(Direction $direction): View|Application|Factory|\Illuminate\Contracts\Foundation\Application

View File

@ -2,8 +2,6 @@
namespace Database\Seeders; namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\Faculty;
use App\Models\User; use App\Models\User;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -14,19 +12,21 @@ class DatabaseSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
// User::factory(10)->create(); User::factory()->create([
// 'name' => 'admin',
User::factory()->create([ 'email' => 'test@example.com',
'name' => 'admin', 'password' => 123456
'email' => 'test@example.com', ]);
'password' => 123456
]); User::factory(10)->create();
$this->call([ $this->call([
ReceptionScreenSeeder::class, ReceptionScreenSeeder::class,
FileSeeder::class, DocumentSeeder::class,
EducationalInstitutionSeeder::class, EducationalInstitutionSeeder::class,
FacultySeeder::class, FacultySeeder::class,
DepartmentSeeder::class, DepartmentSeeder::class,
DirectionSeeder::class,
]); ]);
} }
} }

View File

@ -1,13 +1,3 @@
@php
use App\Models\Direction;
use App\Models\Department;
use App\Models\EducationalInstitution;use App\Models\Faculty;use Illuminate\Support\Collection;
/** @var Collection|Direction[] $direction */
$department = Department::find($direction->department->id);
$faculty = Faculty::find($department->faculty->id);
$educationalInstitution = EducationalInstitution::find($faculty->educationalInstitution->id);
@endphp
@extends('layouts.admin-layout') @extends('layouts.admin-layout')
@section('content') @section('content')
@auth() @auth()

View File

@ -4,16 +4,16 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h1 class="">Прикрепить файл</h1> <h1 class="">Прикрепить файл</h1>
{{ Form::open(array('url' => route('files.store'), 'method' => 'POST', 'files'=>'true')) }} {{ Form::open(['url' => route('documents.store'), 'method' => 'POST', 'files'=>'true']) }}
<div class="mt-2"> <div class="mt-2">
{{ Form::label('url', 'Путь к файлу') }} {{ Form::label('document', 'Путь к документу') }}
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ Form::file('url', ['class' => 'form-control']) }} {{ Form::file('document', ['class' => 'form-control']) }}
</div> </div>
<div> <div>
@if ($errors->any()) @if ($errors->any())
{{ $errors->first('url') }} {{ $errors->first('document') }}
@endif @endif
</div> </div>
<div class="mt-2"> <div class="mt-2">
@ -42,7 +42,7 @@
{{ Form::label('idReceptionScreen', 'Пункт экрана приема') }} {{ Form::label('idReceptionScreen', 'Пункт экрана приема') }}
</div> </div>
<div class="mt-2"> <div class="mt-2">
{{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, ['class' => 'form-select']) }} {{ Form::select('idReceptionScreen', $receptionScreens, null, ['class' => 'form-select']) }}
</div> </div>
<div> <div>
@if ($errors->any()) @if ($errors->any())
@ -54,26 +54,26 @@
</div> </div>
{{Form::close()}} {{Form::close()}}
</div> </div>
@if($idReceptionScreen !== null) {{-- @if($idReceptionScreen !== null)--}}
<div class="col"> {{-- <div class="col">--}}
<h2>Файлы пункта Экрана Приема: {{ $receptionScreens[$idReceptionScreen] }}</h2> {{-- <h2>Файлы пункта Экрана Приема: {{ $receptionScreens[$idReceptionScreen] }}</h2>--}}
<table class="table"> {{-- <table class="table">--}}
<thead class="border-b-2 border-solid border-black text-left" style="text-align: left"> {{-- <thead class="border-b-2 border-solid border-black text-left" style="text-align: left">--}}
<tr> {{-- <tr>--}}
<th scope="col">Позиция</th> {{-- <th scope="col">Позиция</th>--}}
<th scope="col">Название</th> {{-- <th scope="col">Название</th>--}}
</tr> {{-- </tr>--}}
</thead> {{-- </thead>--}}
<tbody> {{-- <tbody>--}}
@foreach($files as $file) {{-- @foreach($files as $file)--}}
<tr> {{-- <tr>--}}
<th scope="row">{{ $file->position }}</th> {{-- <th scope="row">{{ $file->position }}</th>--}}
<th scope="row">{{ $file->name }}</th> {{-- <th scope="row">{{ $file->name }}</th>--}}
@endforeach {{-- @endforeach--}}
</tbody> {{-- </tbody>--}}
</table> {{-- </table>--}}
</div> {{-- </div>--}}
@endif {{-- @endif--}}
</div> </div>
@endauth @endauth
@endsection @endsection