Compare commits

...

5 Commits

Author SHA1 Message Date
aslan 77a0aacf02 add files from Merge pull request 'completing all pages in categories' (#9) from RomanGolienko/Roman_applicant-site:main into main
Tests & Lint & Deploy to Railway / build (20.x, 8.2) (push) Failing after 1m58s Details
Tests & Lint & Deploy to Railway / deploy (8.1) (push) Has been skipped Details
2024-01-26 11:18:34 +03:00
aslan 5cafe2294f add nullable for description field for files table 2024-01-26 11:17:12 +03:00
aslan 252c06e020 delete not users code for blade template 2024-01-26 11:16:20 +03:00
aslan 541963fbc3 update composer.lock 2024-01-26 11:15:22 +03:00
aslan 95deb4cefe add file resource 2024-01-26 11:15:11 +03:00
14 changed files with 443 additions and 80 deletions

View File

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreFileRequest;
use App\Http\Requests\StoreReceptionScreenRequest;
use App\Http\Requests\UpdateFileRequest;
use App\Http\Requests\UpdateReceptionScreenRequest;
use App\Models\File;
use App\Models\ReceptionScreen;
use App\Services\WorkWithFiles;
use Carbon\Carbon;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth;
class FileController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::guest(), 403);
$files = File::all()->sortBy('position');
return view('files.index', compact('files'));
}
public function create($idReceptionScreen = null): View
{
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::pluck('name', 'id');
$idsReceptionScreens = $receptionScreens->keys()->toArray();
$files = File::where('reception_screen_id', '=', $idReceptionScreen)->get();
return view('files.create', compact('receptionScreens', 'idsReceptionScreens', 'idReceptionScreen', 'files'));
}
public function store(StoreFileRequest $request)
{
abort_if(Auth::guest(), 403);
$content = $request->file('url');
WorkWithFiles::saveFileToUploads($content);
$newPath = WorkWithFiles::renameFile($content);
$validated = $request->validated();
$file = new File();
$file->name = $validated['name'];
$file->url = $newPath;
$file->position = $validated['position'];
$file->reception_screen_id = $validated['idReceptionScreen'];
$file->save();
return redirect()->route('files.index');
}
public function edit(int $idFile)
{
abort_if(Auth::guest(), 403);
$file = (new File())->find($idFile);
$files = File::where('reception_screen_id', '=', $file->reception_screen_id)->get();
$receptionScreens = ReceptionScreen::pluck('name', 'id');
$idsReceptionScreens = $receptionScreens->keys()->toArray();
$idReceptionScreen = $file->reception_screen_id;
return view('files.edit', compact('receptionScreens', 'idsReceptionScreens', 'idReceptionScreen', 'files', 'file'));
}
public function update(UpdateFileRequest $request, File $file)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$file->name = $validated['name'];
$file->position = $validated['position'];
$file->reception_screen_id = $validated['idReceptionScreen'];
$file->save();
return redirect()->route('admin-reception-screen.index');
}
public function destroy($idFile)
{
abort_if(Auth::guest(), 403);
$file = (new File())->find($idFile);
$file->delete();
return redirect()->route('admin-reception-screen.index');
}
}

View File

@ -18,6 +18,8 @@ class ReceptionScreenController extends Controller
}
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
abort_if(Auth::guest(), 403);
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('receptionScreens'));
}
@ -32,6 +34,8 @@ class ReceptionScreenController extends Controller
public function store(StoreReceptionScreenRequest $request)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$receptionScreen->name = $validated['name'];
@ -52,6 +56,8 @@ class ReceptionScreenController extends Controller
public function update(UpdateReceptionScreenRequest $request, $id)
{
abort_if(Auth::guest(), 403);
$validated = $request->validated();
$receptionScreen = new ReceptionScreen();
$currentReceptionScreen = $receptionScreen->find($id);

View File

@ -6,10 +6,6 @@ use Illuminate\Http\Request;
class UploadFileController extends Controller
{
public function index()
{
return view('uploadfile');
}
public function showUploadFile(Request $request)
{
$file = $request->file('image');

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreFileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'max:255',
'position' => 'int|max:255',
'url' => 'file',
'idReceptionScreen' => 'int|max:255',
];
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateFileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => 'required|max:255',
'position' => 'required||int|max:255',
'idReceptionScreen' => 'int|max:255',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Services;
use Carbon\Carbon;
class WorkWithFiles
{
public static function saveFileToUploads($content)
{
$destinationPath = 'uploads';
$content->move($destinationPath, $content->getClientOriginalName());
}
public static function renameFile($content)
{
$nameChunks = explode('.', $content->getClientOriginalName());
array_splice($nameChunks, 1);
$timestamp = Carbon::now();
$name = implode('.', $nameChunks);
$newName = "{$name}{$timestamp}.{$content->getClientOriginalExtension()}";
$dir = __DIR__;
$path = "{$dir}/../../public/uploads/";
$oldName = $content->getClientOriginalName();
rename("{$path}{$oldName}", "{$path}{$newName}");
return "{$path}{$newName}";
}
}

110
composer.lock generated
View File

@ -1047,16 +1047,16 @@
},
{
"name": "laravel/framework",
"version": "v10.41.0",
"version": "v10.42.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012"
"reference": "fef1aff874a6749c44f8e142e5764eab8cb96890"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/da31969bd35e6ee0bbcd9e876f88952dc754b012",
"reference": "da31969bd35e6ee0bbcd9e876f88952dc754b012",
"url": "https://api.github.com/repos/laravel/framework/zipball/fef1aff874a6749c44f8e142e5764eab8cb96890",
"reference": "fef1aff874a6749c44f8e142e5764eab8cb96890",
"shasum": ""
},
"require": {
@ -1248,7 +1248,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2024-01-16T15:23:58+00:00"
"time": "2024-01-23T15:07:56+00:00"
},
{
"name": "laravel/prompts",
@ -2131,16 +2131,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.72.1",
"version": "2.72.2",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78"
"reference": "3e7edc41b58d65509baeb0d4a14c8fa41d627130"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2b3b3db0a2d0556a177392ff1a3bf5608fa09f78",
"reference": "2b3b3db0a2d0556a177392ff1a3bf5608fa09f78",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/3e7edc41b58d65509baeb0d4a14c8fa41d627130",
"reference": "3e7edc41b58d65509baeb0d4a14c8fa41d627130",
"shasum": ""
},
"require": {
@ -2234,35 +2234,35 @@
"type": "tidelift"
}
],
"time": "2023-12-08T23:47:49+00:00"
"time": "2024-01-19T00:21:53+00:00"
},
{
"name": "nette/schema",
"version": "v1.2.5",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/nette/schema.git",
"reference": "0462f0166e823aad657c9224d0f849ecac1ba10a"
"reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/schema/zipball/0462f0166e823aad657c9224d0f849ecac1ba10a",
"reference": "0462f0166e823aad657c9224d0f849ecac1ba10a",
"url": "https://api.github.com/repos/nette/schema/zipball/a6d3a6d1f545f01ef38e60f375d1cf1f4de98188",
"reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188",
"shasum": ""
},
"require": {
"nette/utils": "^2.5.7 || ^3.1.5 || ^4.0",
"php": "7.1 - 8.3"
"nette/utils": "^4.0",
"php": "8.1 - 8.3"
},
"require-dev": {
"nette/tester": "^2.3 || ^2.4",
"nette/tester": "^2.4",
"phpstan/phpstan-nette": "^1.0",
"tracy/tracy": "^2.7"
"tracy/tracy": "^2.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
"dev-master": "1.3-dev"
}
},
"autoload": {
@ -2294,9 +2294,9 @@
],
"support": {
"issues": "https://github.com/nette/schema/issues",
"source": "https://github.com/nette/schema/tree/v1.2.5"
"source": "https://github.com/nette/schema/tree/v1.3.0"
},
"time": "2023-10-05T20:37:59+00:00"
"time": "2023-12-11T11:54:22+00:00"
},
{
"name": "nette/utils",
@ -6230,16 +6230,16 @@
},
{
"name": "doctrine/dbal",
"version": "3.7.2",
"version": "3.7.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "0ac3c270590e54910715e9a1a044cc368df282b2"
"reference": "ce594cbc39a4866c544f1a970d285ff0548221ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/0ac3c270590e54910715e9a1a044cc368df282b2",
"reference": "0ac3c270590e54910715e9a1a044cc368df282b2",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/ce594cbc39a4866c544f1a970d285ff0548221ad",
"reference": "ce594cbc39a4866c544f1a970d285ff0548221ad",
"shasum": ""
},
"require": {
@ -6255,14 +6255,14 @@
"doctrine/coding-standard": "12.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.1",
"phpstan/phpstan": "1.10.42",
"phpstan/phpstan": "1.10.56",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "9.6.13",
"phpunit/phpunit": "9.6.15",
"psalm/plugin-phpunit": "0.18.4",
"slevomat/coding-standard": "8.13.1",
"squizlabs/php_codesniffer": "3.7.2",
"symfony/cache": "^5.4|^6.0",
"symfony/console": "^4.4|^5.4|^6.0",
"squizlabs/php_codesniffer": "3.8.1",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/console": "^4.4|^5.4|^6.0|^7.0",
"vimeo/psalm": "4.30.0"
},
"suggest": {
@ -6323,7 +6323,7 @@
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/3.7.2"
"source": "https://github.com/doctrine/dbal/tree/3.7.3"
},
"funding": [
{
@ -6339,7 +6339,7 @@
"type": "tidelift"
}
],
"time": "2023-11-19T08:06:58+00:00"
"time": "2024-01-21T07:53:09+00:00"
},
{
"name": "doctrine/deprecations",
@ -6728,16 +6728,16 @@
},
{
"name": "laravel/pint",
"version": "v1.13.9",
"version": "v1.13.10",
"source": {
"type": "git",
"url": "https://github.com/laravel/pint.git",
"reference": "e3e269cc5d874c8efd2dc7962b1c7ff2585fe525"
"reference": "e2b5060885694ca30ac008c05dc9d47f10ed1abf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/pint/zipball/e3e269cc5d874c8efd2dc7962b1c7ff2585fe525",
"reference": "e3e269cc5d874c8efd2dc7962b1c7ff2585fe525",
"url": "https://api.github.com/repos/laravel/pint/zipball/e2b5060885694ca30ac008c05dc9d47f10ed1abf",
"reference": "e2b5060885694ca30ac008c05dc9d47f10ed1abf",
"shasum": ""
},
"require": {
@ -6748,8 +6748,8 @@
"php": "^8.1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.47.0",
"illuminate/view": "^10.40.0",
"friendsofphp/php-cs-fixer": "^3.47.1",
"illuminate/view": "^10.41.0",
"larastan/larastan": "^2.8.1",
"laravel-zero/framework": "^10.3.0",
"mockery/mockery": "^1.6.7",
@ -6790,20 +6790,20 @@
"issues": "https://github.com/laravel/pint/issues",
"source": "https://github.com/laravel/pint"
},
"time": "2024-01-16T17:39:29+00:00"
"time": "2024-01-22T09:04:15+00:00"
},
{
"name": "laravel/sail",
"version": "v1.27.1",
"version": "v1.27.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/sail.git",
"reference": "9dc648978e4276f2bfd37a076a52e3bd9394777f"
"reference": "2276a8d9d6cfdcaad98bf67a34331d100149d5b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/sail/zipball/9dc648978e4276f2bfd37a076a52e3bd9394777f",
"reference": "9dc648978e4276f2bfd37a076a52e3bd9394777f",
"url": "https://api.github.com/repos/laravel/sail/zipball/2276a8d9d6cfdcaad98bf67a34331d100149d5b6",
"reference": "2276a8d9d6cfdcaad98bf67a34331d100149d5b6",
"shasum": ""
},
"require": {
@ -6855,7 +6855,7 @@
"issues": "https://github.com/laravel/sail/issues",
"source": "https://github.com/laravel/sail"
},
"time": "2024-01-13T18:46:48+00:00"
"time": "2024-01-21T17:13:42+00:00"
},
{
"name": "mockery/mockery",
@ -7366,16 +7366,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.10.56",
"version": "1.10.57",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "27816a01aea996191ee14d010f325434c0ee76fa"
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/27816a01aea996191ee14d010f325434c0ee76fa",
"reference": "27816a01aea996191ee14d010f325434c0ee76fa",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e",
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e",
"shasum": ""
},
"require": {
@ -7424,7 +7424,7 @@
"type": "tidelift"
}
],
"time": "2024-01-15T10:43:00+00:00"
"time": "2024-01-24T11:51:34+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -7749,16 +7749,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.5.8",
"version": "10.5.9",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e"
"reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/08f4fa74d5fbfff1ef22abffee47aaedcaea227e",
"reference": "08f4fa74d5fbfff1ef22abffee47aaedcaea227e",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe",
"reference": "0bd663704f0165c9e76fe4f06ffa6a1ca727fdbe",
"shasum": ""
},
"require": {
@ -7830,7 +7830,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.8"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.9"
},
"funding": [
{
@ -7846,7 +7846,7 @@
"type": "tidelift"
}
],
"time": "2024-01-19T07:07:27+00:00"
"time": "2024-01-22T14:35:40+00:00"
},
{
"name": "psr/cache",

View File

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

View File

@ -43,11 +43,11 @@
<tr>
<th scope="row">{{ $file->position }}</th>
<td>{{ $file->name }}</td>
<td><a href="{{ route("admin-reception-screen.edit", $file) }}"
<td><a href="{{ route("files.edit", $file) }}"
class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete"
data-confirm="Вы действительно хотите удалить?"
href="{{ route('admin-reception-screen.destroy', $file) }}"
href="{{ route('files.destroy', $file) }}"
class="btn btn-danger">
удалить
</a>
@ -58,7 +58,7 @@
</tbody>
</table>
<div class="mb-2">
<a href="{{ route('admin-reception-screen.create') }}"
<a href="{{ route('files.create', $receptionScreen->id) }}"
class="btn btn-primary">
Добавить файл
</a>
@ -68,7 +68,8 @@
@else
<tr>
<td colspan="3">
<a href="{{ route('admin-reception-screen.create') }}" class="btn btn-primary">Добавить
@php($idReceptionScreen = $receptionScreen->id)
<a href="{{ route('files.create', $idReceptionScreen) }}" class="btn btn-primary">Добавить
файл</a>
</td>
</tr>
@ -78,11 +79,5 @@
</table>
<br>
<br>
{{ Form::open(array('url' => route('uploadfile'), 'method' => 'POST', 'files'=>'true')) }}
Select the file to upload.
{{ Form::file('image') }}
{{ Form::submit('Upload File')}}
{{Form::close()}}
</div>
@endsection

View File

@ -0,0 +1,79 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class="">Прикрепить файл</h1>
{{ Form::open(array('url' => route('files.store'), 'method' => 'POST', 'files'=>'true')) }}
<div class="mt-2">
{{ Form::label('url', 'Путь к файлу') }}
</div>
<div class="mt-2">
{{ Form::file('url', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('url') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('name', 'Имя файла') }}
</div>
<div class="mt-2">
{{ Form::text('name', '', ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', 0, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('idReceptionScreen', 'Пункт экрана приема') }}
</div>
<div class="mt-2">
{{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, $idsReceptionScreens,['class' => 'form-select']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('idReceptionScreen') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Загрузить файл', ['class' => 'btn btn-primary'])}}
</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
</div>
@endauth
@endsection

View File

@ -0,0 +1,68 @@
@extends('layouts.admin-layout')
@section('content')
@auth()
<div class="row">
<div class="col">
<h1 class="">Изменить файл</h1>
{{ Form::open(array('url' => route('files.update', $file), 'method' => 'PATCH', 'files'=>'true')) }}
<div class="mt-2">
{{ Form::label('name', 'Имя файла') }}
</div>
<div class="mt-2">
{{ Form::text('name', $file->name, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', $file->position, ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('name') }}
@endif
</div>
<div class="mt-2">
{{ Form::label('idReceptionScreen', 'Пункт экрана приема') }}
</div>
<div class="mt-2">
{{ Form::select('idReceptionScreen', $receptionScreens, $idReceptionScreen, $idsReceptionScreens,['class' => 'form-select']) }}
</div>
<div>
@if ($errors->any())
{{ $errors->first('idReceptionScreen') }}
@endif
</div>
<div class="mt-4">
{{ Form::submit('Загрузить файл', ['class' => 'btn btn-primary'])}}
</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
</div>
@endauth
@endsection

View File

@ -0,0 +1,36 @@
@extends('layouts.admin-layout')
@section('content')
<div class="container">
<h2>Файлы</h2>
<br>
<a href="{{ route('files.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>
<th scope="col">действия</th>
</tr>
</thead>
<tbody>
@foreach($files as $file)
<tr>
<th scope="row">{{ $file->position }}</th>
<td>{{ $file->name }}</td>
<td>{{ $file->receptionScreen->name }}</td>
<td><a href="{{ route("files.edit", $file) }}" class="btn btn-secondary">редактировать</a>
<a rel="nofollow" data-method="delete" data-confirm="Вы действительно хотите удалить?"
href="{{ route('files.destroy', $file) }}" class="btn btn-danger">
удалить
</a>
</td>
@endforeach
</tbody>
</table>
<br>
<br>
</div>
@endsection

View File

@ -33,11 +33,5 @@
</table>
<br>
<br>
{{ Form::open(array('url' => route('uploadfile'), 'method' => 'POST', 'files'=>'true')) }}
Select the file to upload.
{{ Form::file('image') }}
{{ Form::submit('Upload File')}}
{{Form::close()}}
</div>
@endsection

View File

@ -1,5 +1,6 @@
<?php
use App\Http\Controllers\FileController;
use App\Http\Controllers\ReceptionScreenController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UploadFileController;
@ -21,10 +22,15 @@ Route::get('/', function () {
return view('home');
})->name('home');
Route::resources([
'/users' => UserController::class,
'/admin-reception-screen' => ReceptionScreenController::class
]);
Route::resource('/users', UserController::class)->middleware(['auth', 'verified']);
Route::resource('/admin-reception-screen', ReceptionScreenController::class)->middleware(['auth', 'verified']);
//Route::resource('/files', FileController::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('/course', function () {
return view('menu.course');