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\Requests\admin\Catalog\StoreDirectionRequest;
use App\Http\Requests\admin\Catalog\UpdateDepartmentRequest;
use App\Http\Requests\admin\Catalog\UpdateDirectionRequest;
use App\Models\Department;
use App\Models\Direction;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
@ -44,7 +44,18 @@ class DirectionController extends Controller
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

View File

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

View File

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