Compare commits

..

4 Commits

Author SHA1 Message Date
aslan ebade01982 add refresh to migrate artisan method
Tests & Lint & Deploy to Railway / build (20.x, 8.3) (push) Successful in 2m24s Details
Tests & Lint & Deploy to Railway / deploy (push) Successful in 20s Details
2024-02-07 16:34:24 +03:00
aslan b11015ae8f refactored Educational Institutions 2024-02-07 16:34:04 +03:00
aslan 93592992b7 refactored file migration, view and controller 2024-02-07 16:33:34 +03:00
aslan b1cd352165 refactored routes 2024-02-07 16:32:42 +03:00
14 changed files with 141 additions and 121 deletions

View File

@ -9,7 +9,7 @@ setup:
cp -n .env.example .env cp -n .env.example .env
php artisan key:gen --ansi php artisan key:gen --ansi
touch database/database.sqlite touch database/database.sqlite
php artisan migrate php artisan migrate:refresh
php artisan db:seed php artisan db:seed
npm ci npm ci
npm run build npm run build

View File

@ -14,12 +14,12 @@ class EducationalInstitutionController extends Controller
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{ {
$educationalInstitutions = EducationalInstitution::all(); $educationalInstitutions = EducationalInstitution::all();
return view('educational-institution.index', compact('educationalInstitutions')); return view('catalog.educational-institution.index', compact('educationalInstitutions'));
} }
public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{ {
return view('educational-institution.create'); return view('catalog.educational-institution.create');
} }
public function store(StoreEducationalInstitutionRequest $request) public function store(StoreEducationalInstitutionRequest $request)
@ -37,12 +37,12 @@ class EducationalInstitutionController extends Controller
public function show(EducationalInstitution $educationalInstitution) public function show(EducationalInstitution $educationalInstitution)
{ {
return view('educational-institution.show', compact('educationalInstitution')); return view('catalog.educational-institution.show', compact('educationalInstitution'));
} }
public function edit(EducationalInstitution $educationalInstitution) public function edit(EducationalInstitution $educationalInstitution)
{ {
return view('educational-institution.edit', compact('educationalInstitution')); return view('catalog.educational-institution.edit', compact('educationalInstitution'));
} }
public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution) public function update(UpdateEducationalInstitutionRequest $request, EducationalInstitution $educationalInstitution)
@ -59,6 +59,9 @@ class EducationalInstitutionController extends Controller
public function destroy(EducationalInstitution $educationalInstitution) public function destroy(EducationalInstitution $educationalInstitution)
{ {
if ($educationalInstitution->faculties()->exists()) {
return back();
}
$educationalInstitution->delete(); $educationalInstitution->delete();
return redirect()->route('educational-institutions.index'); return redirect()->route('educational-institutions.index');

View File

@ -35,9 +35,8 @@ class FileController extends Controller
abort_if(Auth::guest(), 403); abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::pluck('name', 'id'); $receptionScreens = ReceptionScreen::pluck('name', 'id');
$idsReceptionScreens = $receptionScreens->keys()->toArray();
$files = File::where('reception_screen_id', '=', $idReceptionScreen)->get(); $files = File::where('reception_screen_id', '=', $idReceptionScreen)->get();
return view('files.create', compact('receptionScreens', 'idsReceptionScreens', 'idReceptionScreen', 'files')); return view('files.create', compact('receptionScreens', 'idReceptionScreen', 'files'));
} }
public function store(StoreFileRequest $request) public function store(StoreFileRequest $request)

View File

@ -4,8 +4,21 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class EducationalInstitution extends Model class EducationalInstitution extends Model
{ {
use HasFactory; use HasFactory;
protected $fillable = [
'id',
'name',
'description',
'position',
];
public function faculties(): HasMany
{
return $this->hasMany('App\Models\Faculty', 'educational_institution_id');
}
} }

View File

@ -13,6 +13,7 @@ class File extends Model
protected $fillable = [ protected $fillable = [
'id', 'id',
'name', 'name',
'file_name',
'url', 'url',
'description', 'description',
]; ];

View File

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('files', function (Blueprint $table) { Schema::create('files', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->string('file_name')->nullable();
$table->string('description')->nullable(); $table->string('description')->nullable();
$table->string('url'); $table->string('url');
$table->integer('position'); $table->integer('position');

View File

@ -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, $idsReceptionScreens,['class' => 'form-select']) }} {{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, ['class' => 'form-select']) }}
</div> </div>
<div> <div>
@if ($errors->any()) @if ($errors->any())

View File

@ -13,11 +13,12 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</head> </head>
<body class="antialiased"> <body class="antialiased">
<div class="container"> <div class="container-fluid">
<header <header
class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom"> class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom">
<ul class="nav col-9 col-md-auto mb-2 justify-content-start mb-md-0"> <ul class="nav col-9 col-md-auto mb-2 justify-content-start mb-md-0">
<li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a></li> <li><a href="{{ route('dashboard') }}" class="nav-link px-2 link-secondary text-wrap" style="width: 4rem;">Главная</a>
</li>
</ul> </ul>
@ -52,10 +53,14 @@
<li class="list-group-item"><a href="{{ route('files.index') }}">Файлы</a></li> <li class="list-group-item"><a href="{{ route('files.index') }}">Файлы</a></li>
<li class="list-group-item"><a href="{{ route('admin-reception-screen.index') }}">Экран Приема</a></li> <li class="list-group-item"><a href="{{ route('admin-reception-screen.index') }}">Экран Приема</a></li>
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin') @if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
{{-- <li class="list-group-item"></li>--}} <li class="list-group-item"></li>
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li> <li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
<li class="list-group-item"><a href="{{ route('educational-institutions.index') }}">Учебные заведения</a></li>
@endif @endif
<li class="list-group-item"></li>
<li class="list-group-item">Справочники</li>
<li class="list-group-item"><a href="{{ route('educational-institutions.index') }}">Учебные
заведения</a></li>
<li class="list-group-item"><a href="{{ route('faculties.index') }}">Факультеты</a></li>
</ul> </ul>
</aside> </aside>
<div class="col-10">@yield('content')</div> <div class="col-10">@yield('content')</div>

20
routes/admin.php Normal file
View File

@ -0,0 +1,20 @@
<?php
use App\Http\Controllers\EducationalInstitutionController;
use App\Http\Controllers\FacultyController;
use App\Http\Controllers\FileController;
use App\Http\Controllers\ReceptionScreenController;
use App\Http\Controllers\UserController;
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/files/create/{file?}', [FileController::class, 'create'])->name('files.create');
Route::get('/files/download/{file}', [FileController::class, 'download'])->name('files.download');
Route::resources([
'/files' => FileController::class,
'/users' => UserController::class,
'/admin-reception-screen' => ReceptionScreenController::class,
'/educational-institutions' => EducationalInstitutionController::class,
'/faculties' => FacultyController::class,
]);
});

84
routes/pages/web.php Normal file
View File

@ -0,0 +1,84 @@
<?php
use App\Http\Controllers\PageController;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('home');
})->name('home');
Route::get('/course', function () {
return view('menu.course');
})->name('course');
Route::get('/applicant', function () {
return view('menu.abitur');
})->name('abitur');
Route::get('/for-foreign-applicants', function () {
return view('menu.inostrannym-abiturientam');
})->name('inostrannym-abiturientam');
Route::get('/paid_edu', function () {
return view('menu.paid_edu');
})->name('paid_edu');
Route::get('/olympiads-for-schoolchildren', function () {
return view('menu.olimpiady-dlya-shkolnikov');
})->name('olimpiady-dlya-shkolnikov');
Route::get('/training courses', function () {
return view('menu.podgotovitelnye-kursy');
})->name('podgotovitelnye-kursy');
Route::get('/reception-screens', [PageController::class, 'index'])->name('reception-screens');
Route::get('/web-consultations', function () {
return view('menu.abitur.web-consultations');
})->name('web-consultations');
Route::get('/specialty-magistracy', function () {
return view('menu.abitur.spetsialitet-magistratura');
})->name('spetsialitet-magistratura');
Route::get('/college', function () {
return view('menu.abitur.kolledzh');
})->name('kolledzh');
Route::get('/paid-educational-services', function () {
return view('menu.abitur.platnye-obrazovatelnye-uslugi');
})->name('platnye-obrazovatelnye-uslugi');
Route::get('/residency', function () {
return view('menu.abitur.ordinatura');
})->name('ordinatura');
Route::get('/traineeship', function () {
return view('menu.abitur.aspirantura');
})->name('aspirantura');
Route::get('/video-materials-for-applicants', function () {
return view('menu.abitur.videomaterialy-dlya-postupayushchikh');
})->name('videomaterialy-dlya-postupayushchikh');
Route::get('/international-activity', function () {
return view('menu.inostrannym-abiturientam.mezhdunarodnaya-deyatelnost');
})->name('mezhdunarodnaya-deyatelnost');
Route::get('/general-information', function () {
return view('menu.inostrannym-abiturientam.obshchie-svedeniya');
})->name('obshchie-svedeniya');
Route::get('/departments', function () {
return view('menu.inostrannym-abiturientam.kafedry');
})->name('kafedry');
Route::get('/international-education-center', function () {
return view('menu.inostrannym-abiturientam.tsentr-mezhdunarodnogo-obrazovaniya');
})->name('tsentr-mezhdunarodnogo-obrazovaniya');
Route::get('/academic-mobility-and-international-cooperation', function () {
return view('menu.inostrannym-abiturientam.akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');
})->name('akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');

View File

@ -1,116 +1,8 @@
<?php <?php
use App\Http\Controllers\EducationalInstitutionController;
use App\Http\Controllers\FileController;
use App\Http\Controllers\PageController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\ReceptionScreenController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('home');
})->name('home');
Route::resource('/users', UserController::class)->middleware(['auth', 'verified']);
Route::resource('/admin-reception-screen', ReceptionScreenController::class)->middleware(['auth', 'verified']);
Route::resource('/educational-institutions', EducationalInstitutionController::class)->middleware(['auth', 'verified']);
Route::get('/files', [FileController::class, 'index'])->name('files.index');
Route::post('/files', [FileController::class, 'store'])->name('files.store');
Route::get('/files/create/{file?}', [FileController::class, 'create'])->name('files.create');
Route::patch('/files/{file}', [FileController::class, 'update'])->name('files.update');
Route::delete('files/{file}', [FileController::class, 'destroy'])->name('files.destroy');
Route::get('/files/edit/{file}', [FileController::class, 'edit'])->name('files.edit');
Route::get('/files/download/{file}', [FileController::class, 'download'])->name('files.download');
Route::get('/course', function () {
return view('menu.course');
})->name('course');
Route::get('/applicant', function () {
return view('menu.abitur');
})->name('abitur');
Route::get('/for-foreign-applicants', function () {
return view('menu.inostrannym-abiturientam');
})->name('inostrannym-abiturientam');
Route::get('/paid_edu', function () {
return view('menu.paid_edu');
})->name('paid_edu');
Route::get('/olympiads-for-schoolchildren', function () {
return view('menu.olimpiady-dlya-shkolnikov');
})->name('olimpiady-dlya-shkolnikov');
Route::get('/training courses', function () {
return view('menu.podgotovitelnye-kursy');
})->name('podgotovitelnye-kursy');
Route::get('/reception-screens', [PageController::class, 'index'])->name('reception-screens');
Route::get('/web-consultations', function () {
return view('menu.abitur.web-consultations');
})->name('web-consultations');
Route::get('/specialty-magistracy', function () {
return view('menu.abitur.spetsialitet-magistratura');
})->name('spetsialitet-magistratura');
Route::get('/college', function () {
return view('menu.abitur.kolledzh');
})->name('kolledzh');
Route::get('/paid-educational-services', function () {
return view('menu.abitur.platnye-obrazovatelnye-uslugi');
})->name('platnye-obrazovatelnye-uslugi');
Route::get('/residency', function () {
return view('menu.abitur.ordinatura');
})->name('ordinatura');
Route::get('/traineeship', function () {
return view('menu.abitur.aspirantura');
})->name('aspirantura');
Route::get('/video-materials-for-applicants', function () {
return view('menu.abitur.videomaterialy-dlya-postupayushchikh');
})->name('videomaterialy-dlya-postupayushchikh');
Route::get('/international-activity', function () {
return view('menu.inostrannym-abiturientam.mezhdunarodnaya-deyatelnost');
})->name('mezhdunarodnaya-deyatelnost');
Route::get('/general-information', function () {
return view('menu.inostrannym-abiturientam.obshchie-svedeniya');
})->name('obshchie-svedeniya');
Route::get('/departments', function () {
return view('menu.inostrannym-abiturientam.kafedry');
})->name('kafedry');
Route::get('/international-education-center', function () {
return view('menu.inostrannym-abiturientam.tsentr-mezhdunarodnogo-obrazovaniya');
})->name('tsentr-mezhdunarodnogo-obrazovaniya');
Route::get('/academic-mobility-and-international-cooperation', function () {
return view('menu.inostrannym-abiturientam.akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');
})->name('akademicheskaya-mobilnost-i-mezhdunarodnoe-sotrudnichestvo');
Route::get('/dashboard', function () { Route::get('/dashboard', function () {
return view('admin'); return view('admin');
})->middleware(['auth', 'verified'])->name('dashboard'); })->middleware(['auth', 'verified'])->name('dashboard');
@ -122,3 +14,5 @@ Route::middleware('auth')->group(function () {
}); });
require __DIR__ . '/auth.php'; require __DIR__ . '/auth.php';
require __DIR__ . '/admin.php';
require __DIR__ . '/pages/web.php';