Compare commits
No commits in common. "1155f2c34aed7abd088eb8ee763b5483458cd1c8" and "056452b1370abfd50053a40ab7e9527b0e134e9f" have entirely different histories.
1155f2c34a
...
056452b137
|
@ -1,98 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Direction;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
|
||||
class DirectionsExport implements WithMapping, FromQuery, WithHeadings, ShouldAutoSize
|
||||
{
|
||||
public function query()
|
||||
{
|
||||
return Direction::query();
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'Код',
|
||||
'Имя',
|
||||
'Кафедры',
|
||||
'Ур-нь обр.',
|
||||
'Форма обр.',
|
||||
'бюджетные места',
|
||||
'квота',
|
||||
'платн. места',
|
||||
'ст-ть платн. мест',
|
||||
'период',
|
||||
'Профиль подготовки',
|
||||
'вступительные испытания ЕГЕ (Обязательное)',
|
||||
'вступительные испытания ЕГЕ (По выбору)',
|
||||
'вступительные испытания СПО',
|
||||
'вступительные испытания Магистратура'
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
$row->code,
|
||||
$row->name,
|
||||
$row->department->name,
|
||||
$row->educationLevel->name,
|
||||
$row->educationForm->name,
|
||||
$row->budget_places,
|
||||
$row->quota,
|
||||
$row->paid_places,
|
||||
$row->cost_paid_place,
|
||||
$row->period,
|
||||
implode("; ", $row->directionProfiles),
|
||||
implode("; ", $row->egeCompulsory),
|
||||
implode("; ", $row->egeOptional),
|
||||
implode("; ", $row->spo),
|
||||
implode("; ", $row->magistracy),
|
||||
]
|
||||
// $row->entranceExaminations->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function prepareRows($rows)
|
||||
{
|
||||
return $rows->transform(function ($direction) {
|
||||
$profilesNames = [];
|
||||
foreach ($direction->directionProfiles as $profile) {
|
||||
$profilesNames[] = $profile->name;
|
||||
}
|
||||
$direction->directionProfiles = $profilesNames;
|
||||
|
||||
$egeCompulsory = [];
|
||||
$egeOptional = [];
|
||||
$spo = [];
|
||||
$magistracy = [];
|
||||
foreach ($direction->entranceExaminations as $examination) {
|
||||
$subject = $examination->subject->name;
|
||||
$scores = $examination->scores;
|
||||
if ($examination->examinationType->name === 'ЕГЭ') {
|
||||
if ($examination->subjectType->name === 'Обязательные') {
|
||||
$egeCompulsory[] = "{$subject} ({$scores})";
|
||||
} elseif ($examination->subjectType->name === 'Предметы по выбору') {
|
||||
$egeOptional[] = "{$subject} ({$scores})";
|
||||
}
|
||||
} elseif ($examination->examinationType->name === 'СПО') {
|
||||
$spo[] = "{$subject} ({$scores})";
|
||||
} elseif ($examination->examinationType->name === 'магитсратура') {
|
||||
$magistracy[] = "{$subject} ({$scores})";
|
||||
}
|
||||
}
|
||||
$direction->egeCompulsory = $egeCompulsory;
|
||||
$direction->egeOptional = $egeOptional;
|
||||
$direction->spo = $spo;
|
||||
$direction->magistracy = $magistracy;
|
||||
return $direction;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Controllers\admin\Catalog;
|
||||
|
||||
use App\Enums\ExaminationTypeEnum;
|
||||
use App\Exports\DirectionsExport;
|
||||
use App\Helpers\SlugHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\admin\Catalog\StoreDirectionRequest;
|
||||
|
@ -24,7 +23,6 @@ use Illuminate\Foundation\Application;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class DirectionController extends Controller
|
||||
{
|
||||
|
@ -305,9 +303,4 @@ class DirectionController extends Controller
|
|||
|
||||
return redirect()->route('directions.index');
|
||||
}
|
||||
|
||||
public function exportXls()
|
||||
{
|
||||
return Excel::download(new DirectionsExport(), 'directions.xlsx');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,6 @@ class Direction extends Model
|
|||
'position',
|
||||
'slug',
|
||||
'code',
|
||||
'budget_places',
|
||||
'quota',
|
||||
'paid_places',
|
||||
'cost_paid_place',
|
||||
'period',
|
||||
];
|
||||
|
||||
public function department(): BelongsTo
|
||||
|
|
|
@ -3,10 +3,7 @@
|
|||
<div class="container">
|
||||
<h2>Направления</h2>
|
||||
<br>
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-between">
|
||||
<a href="{{ route('directions.create') }}" class="btn btn-primary">Создать Направление</a>
|
||||
<a href="{{ route('export_excel') }}" class="btn btn-info">Импорт xls</a>
|
||||
</div>
|
||||
<a href="{{ route('directions.create') }}" class="btn btn-primary">Создать Направление</a>
|
||||
<br>
|
||||
<br>
|
||||
<table class="table">
|
||||
|
@ -31,7 +28,7 @@
|
|||
<br>
|
||||
<p @style(['font-size: 0.7em', 'color: grey'])>
|
||||
@foreach($direction->directionProfiles as $directionProfile)
|
||||
{{ $directionProfile->name }} <br>
|
||||
{{ $directionProfile->name }}
|
||||
@endforeach
|
||||
</p>
|
||||
</td>
|
||||
|
|
|
@ -18,7 +18,7 @@ use Rap2hpoutre\LaravelLogViewer\LogViewerController;
|
|||
|
||||
Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
|
||||
Route::get('/logs', [LogViewerController::class, 'index']);
|
||||
Route::get('/export_excel', [DirectionController::class, 'exportXls'])->name('export_excel');
|
||||
Route::get('/exportExcel', [LogViewerController::class, 'index']);
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('admin');
|
||||
|
|
Loading…
Reference in New Issue