Compare commits

..

No commits in common. "aaaec23a25cf3ebf8c16fdef68ed337d1ae9f5bb" and "b9dfe9669a0cff50667799a473a22614afe181c8" have entirely different histories.

13 changed files with 0 additions and 399 deletions

View File

@ -3,7 +3,6 @@
namespace App\Helpers;
use App\Models\Direction;
use App\Models\DirectionDescription;
use App\Models\DirectionProfile;
use App\Models\Document;
use App\Models\EntranceExamination;
@ -74,10 +73,4 @@ class PositionHelper
$maxPosition = Document::max('position');
return $maxPosition >= 254 ? 255 : $maxPosition + 1;
}
public static function directionDescription()
{
$maxPosition = DirectionDescription::max('position');
return $maxPosition >= 254 ? 255 : $maxPosition + 1;
}
}

View File

@ -1,72 +0,0 @@
<?php
namespace App\Http\Controllers\admin\Catalog;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\StoreDirectionDescriptionRequest;
use App\Http\Requests\admin\UpdateDirectionDescriptionRequest;
use App\Models\Direction;
use App\Models\DirectionDescription;
use Illuminate\Support\Facades\Storage;
class DirectionDescriptionController extends Controller
{
public function index()
{
$directionDescriptions = DirectionDescription::all();
return view('admin.catalog.direction_description.index', compact('directionDescriptions'));
}
public function create()
{
$directionCodes = Direction::pluck('full_name', 'code');
return view('admin.catalog.direction_description.create', compact('directionCodes'));
}
public function store(StoreDirectionDescriptionRequest $request)
{
$validated = $request->validated();
$fileName = $request->file('file')->getClientOriginalName();
$name = Storage::put('public', $request->file('file'));
$directionDescription = new DirectionDescription();
$directionDescription->url = Storage::url($name);
$directionDescription->direction_code = Direction::select('code', 'id')
->where('code', $validated['direction_code'])
->first()
->id;
$directionDescription->file_name = $fileName;
$directionDescription->position = $validated['position'];
$directionDescription->save();
return redirect()->route('direction_descriptions.index');
}
public function edit(DirectionDescription $directionDescription)
{
$directionCodes = Direction::pluck('full_name', 'code');
return view('admin.catalog.direction_description.edit', compact('directionDescription', 'directionCodes'));
}
public function update(UpdateDirectionDescriptionRequest $request, DirectionDescription $directionDescription)
{
$validated = $request->validated();
$fileName = $request->file('file')->getClientOriginalName();
$name = Storage::put('public', $request->file('file'));
$directionDescription->url = Storage::url($name);
$directionDescription->direction_code = Direction::select('code', 'id')
->where('code', $validated['direction_code'])
->first()
->id;
$directionDescription->file_name = $fileName;
$directionDescription->position = $validated['position'];
$directionDescription->save();
return redirect()->route('direction_descriptions.index');
}
public function destroy(DirectionDescription $directionDescription)
{
$directionDescription->delete();
return redirect()->route('direction_descriptions.index');
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreDirectionDescriptionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'direction_code' => 'required|string|max:255|exists:directions,code',
'file' => 'required|file',
'file_name' => 'nullable|string|max:255',
'position' => 'required|int|numeric|max:255',
];
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace App\Http\Requests\admin;
use Illuminate\Foundation\Http\FormRequest;
class UpdateDirectionDescriptionRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
'direction_code' => 'required|string|max:255|exists:directions,code',
'file' => 'required|file',
'file_name' => 'nullable|string|max:255',
'position' => 'required|int|numeric|max:255',
];
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DirectionDescription extends Model
{
use HasFactory;
protected $fillable = [
'direction_code',
'file_name',
'position',
'url'
];
}

View File

@ -1,25 +0,0 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DirectionDescription>
*/
class DirectionDescriptionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'file_name' => fake()->name(),
'position' => 1,
'url' => fake()->url(),
];
}
}

View File

@ -1,31 +0,0 @@
<?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('direction_descriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('direction_code')->constrained('directions');
$table->string('file_name', 255)->nullable();
$table->string('position', 255);
$table->string('url', 255);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('direction_descriptions');
}
};

View File

@ -1,17 +0,0 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DirectionDescriptionSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@ -1,72 +0,0 @@
@php use App\Helpers\PositionHelper; @endphp
@extends('layouts.admin_layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class="">Прикрепить файл</h1>
{{ Form::open(['url' => route('direction_descriptions.store'), 'method' => 'POST', 'files'=>'true', 'class' => 'needs-validation', 'novalidate']) }}
<div class="mt-3">
{{ Form::label('direction_code', 'Направление', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id')]) }}
<span class="text-danger">*</span>
</div>
<div class="mt-1">
{{ Form::select('direction_code', $directionCodes, null, ['class' => 'form-select', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id'), 'required']) }}
<div class="invalid-feedback">
Поле "Направление" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any())
{{ $errors->first('direction_code') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('file', 'Путь к Файлу', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id')]) }}
<span class="text-danger">*</span>
</div>
<div class="mt-1">
{{ Form::file('file', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id'), 'required']) }}
<div class="invalid-feedback">
Поле "Путь к документу" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any())
{{ $errors->first('file') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('file_name', 'Имя файла') }}
</div>
<div class="mt-1">
{{ Form::text('file_name', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-1">
{{ Form::text('position', PositionHelper::directionDescription(), ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('position') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Загрузить файл', ['class' => 'btn btn-primary'])}}
</div>
{{Form::close()}}
</div>
</div>
@endauth
@endsection

View File

@ -1,71 +0,0 @@
@extends('layouts.admin_layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class="">Заменить файл</h1>
{{ Form::open(['url' => route('direction_descriptions.update', $directionDescription), 'method' => 'PATCH', 'files'=>'true', 'class' => 'needs-validation', 'novalidate']) }}
<div class="mt-3">
{{ Form::label('direction_code', 'Направление', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id')]) }}
<span class="text-danger">*</span>
</div>
<div class="mt-1">
{{ Form::select('direction_code', $directionCodes, null, ['class' => 'form-select', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id'), 'required']) }}
<div class="invalid-feedback">
Поле "Направление" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any())
{{ $errors->first('direction_code') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('file', 'Путь к Файлу', ['data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id')]) }}
<span class="text-danger">*</span>
</div>
<div class="mt-1">
{{ Form::file('file', ['class' => 'form-control', 'data-bs-toggle' => "tooltip", 'data-bs-title' => __('tooltips.direction.department_id'), 'required']) }}
<div class="invalid-feedback">
Поле "Путь к документу" обязательно!
</div>
</div>
<div class="text-danger">
@if ($errors->any())
{{ $errors->first('file') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('file_name', 'Имя файла') }}
</div>
<div class="mt-1">
{{ Form::text('file_name', $directionDescription->file_name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-3">
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-1">
{{ Form::text('position', $directionDescription->position, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('position') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Загрузить файл', ['class' => 'btn btn-primary'])}}
</div>
{{Form::close()}}
</div>
</div>
@endauth
@endsection

View File

@ -1,35 +0,0 @@
@php use App\Models\Direction; @endphp
@extends('layouts.admin_layout')
@section('content')
<div class="container">
<h2>Документы</h2>
<br>
<a href="{{ route('direction_descriptions.create') }}" class="btn btn-primary">Добавить документ</a>
<br>
<br>
<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>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($directionDescriptions as $directionDescription)
<tr>
<td>{{ Str::limit(Direction::where('id', $directionDescription->direction_code)->first()->full_name, 50) }}</td>
<td>{{ $directionDescription->file_name }}</td>
<td><a href="{{ route("direction_descriptions.edit", $directionDescription) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('direction_descriptions.destroy', $directionDescription) }}" class="btn btn-danger">
удалить
</a>
</td>
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endsection

View File

@ -56,9 +56,7 @@
<li class="list-group-item {{ request()->is('admin/feedback*') && !request()->is('admin/feedback_statuses*') ? 'active' : '' }}"><a class="{{ request()->is('admin/feedback*') && !request()->is('admin/feedback_statuses*') ? 'link-light' : '' }}" href="{{ route('feedback.index') }}">Обратная связь</a></li>
<li class="list-group-item {{ request()->is('admin/documents*') ? 'active' : '' }}"><a class="{{ request()->is('admin/documents*') ? 'link-light' : '' }}" href="{{ route('documents.index') }}">Документы</a></li>
<li class="list-group-item {{ request()->is('admin/admissions*') ? 'active' : '' }}"><a class="{{ request()->is('admin/admissions*') ? 'link-light' : '' }}" href="{{ route('admissions.index') }}">Экран Приема</a></li>
<li class="list-group-item"></li>
<li class="list-group-item {{ request()->is('admin/directions*') ? 'active' : '' }}"><a class="{{ request()->is('admin/directions*') ? 'link-light' : '' }}" href="{{ route('directions.index') }}">Направления</a></li>
<li class="list-group-item {{ request()->is('admin/direction_descriptions*') ? 'active' : '' }}"><a class="{{ request()->is('admin/direction_descriptions*') ? 'link-light' : '' }}" href="{{ route('direction_descriptions.index') }}">Файлы для Направлений</a></li>
@can('viewAny', Auth::user())
<li class="list-group-item"></li>
<li class="list-group-item {{ request()->is('admin/users*') ? 'active' : '' }}"><a class="{{ request()->is('admin/users*') ? 'link-light' : '' }}" href="{{ route('users.index') }}">Список администраторов</a></li>

View File

@ -10,7 +10,6 @@ use App\Http\Controllers\admin\Catalog\Direction\ExaminationTypeController;
use App\Http\Controllers\admin\Catalog\Direction\SubjectController;
use App\Http\Controllers\admin\Catalog\Direction\SubjectTypeController;
use App\Http\Controllers\admin\Catalog\DirectionController;
use App\Http\Controllers\admin\Catalog\DirectionDescriptionController;
use App\Http\Controllers\admin\Catalog\EducationalInstitutionController;
use App\Http\Controllers\admin\Catalog\FacultyController;
use App\Http\Controllers\admin\DocumentController;
@ -70,8 +69,6 @@ Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
Route::resource('/direction_profiles', DirectionProfileController::class)
->scoped(['direction_profile' => 'slug']);
Route::resource('/direction_descriptions', DirectionDescriptionController::class)
->scoped(['direction_descriptions' => 'slug']);
Route::resource('/feedback', FeedbackController::class)->only(['index', 'edit', 'update']);
Route::resource('/feedback_statuses', FeedbackStatusController::class);