Compare commits

...

5 Commits

Author SHA1 Message Date
aslan b72fcc938f add Receprion screen view
Tests & Lint & Deploy to Railway / build (20.x, 8.2) (push) Failing after 2m1s Details
Tests & Lint & Deploy to Railway / deploy (8.1) (push) Has been skipped Details
2024-01-30 10:55:31 +03:00
aslan e2fab4b9bd add tests for admin reception screen 2024-01-30 09:17:09 +03:00
aslan 77d0f5e65a delete unused controller 2024-01-30 09:16:21 +03:00
aslan 4a0f077272 add DiDom to project 2024-01-30 09:15:28 +03:00
aslan 58c60a1d9b add htaccess to deployment 2024-01-30 09:15:13 +03:00
9 changed files with 288 additions and 64 deletions

3
.htaccess Normal file
View File

@ -0,0 +1,3 @@
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

View File

@ -14,6 +14,7 @@ use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
class FileController extends Controller class FileController extends Controller
{ {
@ -47,6 +48,10 @@ class FileController extends Controller
WorkWithFiles::saveFileToUploads($content); WorkWithFiles::saveFileToUploads($content);
$newPath = WorkWithFiles::renameFile($content); $newPath = WorkWithFiles::renameFile($content);
$url = $request->file('file');
$return = Storage::put('file.jpg', $content);
dd($return);
$validated = $request->validated(); $validated = $request->validated();
$file = new File(); $file = new File();
$file->name = $validated['name']; $file->name = $validated['name'];

View File

@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use App\Models\ReceptionScreen;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class PageController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$receptionScreens = ReceptionScreen::all()->sortBy('position');
return view('menu.reception-screen', compact('receptionScreens'));
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UploadFileController extends Controller
{
public function showUploadFile(Request $request)
{
$file = $request->file('image');
//Display File Name
echo 'File Name: ' . $file->getClientOriginalName();
echo '<br>';
//Display File Extension
echo 'File Extension: ' . $file->getClientOriginalExtension();
echo '<br>';
//Display File Real Path
echo 'File Real Path: ' . $file->getRealPath();
echo '<br>';
//Display File Size
echo 'File Size: ' . $file->getSize();
echo '<br>';
//Display File Mime Type
echo 'File Mime Type: ' . $file->getMimeType();
//Move Uploaded File
$destinationPath = 'uploads';
$file->move($destinationPath, $file->getClientOriginalName());
}
}

104
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "fdefaf46b5f41fa6a367dece0d5b67f0", "content-hash": "5bc9c65b7acd466b9ce68980e20268db",
"packages": [ "packages": [
{ {
"name": "brick/math", "name": "brick/math",
@ -1045,6 +1045,58 @@
], ],
"time": "2023-12-03T19:50:20+00:00" "time": "2023-12-03T19:50:20+00:00"
}, },
{
"name": "imangazaliev/didom",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/Imangazaliev/DiDOM.git",
"reference": "50fa6595d14f22c0c984efed5c818485cf548136"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Imangazaliev/DiDOM/zipball/50fa6595d14f22c0c984efed5c818485cf548136",
"reference": "50fa6595d14f22c0c984efed5c818485cf548136",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-iconv": "*",
"php": ">=7.2"
},
"require-dev": {
"phpunit/phpunit": "^8.5"
},
"type": "library",
"autoload": {
"psr-4": {
"DiDom\\": "src/DiDom/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Imangazaliev Muhammad",
"email": "imangazalievm@gmail.com"
}
],
"description": "Simple and fast HTML parser",
"homepage": "https://github.com/Imangazaliev/DiDOM",
"keywords": [
"didom",
"html",
"parser",
"xml"
],
"support": {
"issues": "https://github.com/Imangazaliev/DiDOM/issues",
"source": "https://github.com/Imangazaliev/DiDOM/tree/2.0.1"
},
"time": "2023-03-05T03:23:48+00:00"
},
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v10.42.0", "version": "v10.42.0",
@ -1824,16 +1876,16 @@
}, },
{ {
"name": "league/flysystem", "name": "league/flysystem",
"version": "3.23.0", "version": "3.23.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem.git", "url": "https://github.com/thephpleague/flysystem.git",
"reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc" "reference": "199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e",
"reference": "d4ad81e2b67396e33dc9d7e54ec74ccf73151dcc", "reference": "199e1aebbe3e62bd39f4d4fc8c61ce0b3786197e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1898,7 +1950,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/thephpleague/flysystem/issues", "issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.23.0" "source": "https://github.com/thephpleague/flysystem/tree/3.23.1"
}, },
"funding": [ "funding": [
{ {
@ -1910,20 +1962,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-12-04T10:16:17+00:00" "time": "2024-01-26T18:42:03+00:00"
}, },
{ {
"name": "league/flysystem-local", "name": "league/flysystem-local",
"version": "3.23.0", "version": "3.23.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/flysystem-local.git", "url": "https://github.com/thephpleague/flysystem-local.git",
"reference": "5cf046ba5f059460e86a997c504dd781a39a109b" "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/5cf046ba5f059460e86a997c504dd781a39a109b", "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/b884d2bf9b53bb4804a56d2df4902bb51e253f00",
"reference": "5cf046ba5f059460e86a997c504dd781a39a109b", "reference": "b884d2bf9b53bb4804a56d2df4902bb51e253f00",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1958,7 +2010,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/thephpleague/flysystem-local/issues", "issues": "https://github.com/thephpleague/flysystem-local/issues",
"source": "https://github.com/thephpleague/flysystem-local/tree/3.23.0" "source": "https://github.com/thephpleague/flysystem-local/tree/3.23.1"
}, },
"funding": [ "funding": [
{ {
@ -1970,20 +2022,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-12-04T10:14:46+00:00" "time": "2024-01-26T18:25:23+00:00"
}, },
{ {
"name": "league/mime-type-detection", "name": "league/mime-type-detection",
"version": "1.14.0", "version": "1.15.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git", "url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "b6a5854368533df0295c5761a0253656a2e52d9e" "reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b6a5854368533df0295c5761a0253656a2e52d9e", "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"reference": "b6a5854368533df0295c5761a0253656a2e52d9e", "reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2014,7 +2066,7 @@
"description": "Mime-type detection for Flysystem", "description": "Mime-type detection for Flysystem",
"support": { "support": {
"issues": "https://github.com/thephpleague/mime-type-detection/issues", "issues": "https://github.com/thephpleague/mime-type-detection/issues",
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.14.0" "source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0"
}, },
"funding": [ "funding": [
{ {
@ -2026,7 +2078,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2023-10-17T14:13:20+00:00" "time": "2024-01-28T23:22:08+00:00"
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
@ -6230,16 +6282,16 @@
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "3.7.3", "version": "3.8.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "ce594cbc39a4866c544f1a970d285ff0548221ad" "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/ce594cbc39a4866c544f1a970d285ff0548221ad", "url": "https://api.github.com/repos/doctrine/dbal/zipball/d244f2e6e6bf32bff5174e6729b57214923ecec9",
"reference": "ce594cbc39a4866c544f1a970d285ff0548221ad", "reference": "d244f2e6e6bf32bff5174e6729b57214923ecec9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -6323,7 +6375,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/doctrine/dbal/issues", "issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/3.7.3" "source": "https://github.com/doctrine/dbal/tree/3.8.0"
}, },
"funding": [ "funding": [
{ {
@ -6339,7 +6391,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-01-21T07:53:09+00:00" "time": "2024-01-25T21:44:02+00:00"
}, },
{ {
"name": "doctrine/deprecations", "name": "doctrine/deprecations",
@ -9327,7 +9379,7 @@
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": "^8.2" "php": "^8.1|8.2"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.6.0" "plugin-api-version": "2.6.0"

View File

@ -36,7 +36,7 @@
</a> </a>
</div> </div>
<div class="col-lg-3 col-md-4"> <div class="col-lg-3 col-md-4">
<a href="#"> <a href="{{ route('reception-screens') }}">
<div class="tp-feature__item before-color-3 mb-40"> <div class="tp-feature__item before-color-3 mb-40">
<div class="tp-feature__icon"> <div class="tp-feature__icon">
<img style="max-width: 26%;" src="{{ URL::to('img/courses/ekrpriem.png') }}" alt=""> <img style="max-width: 26%;" src="{{ URL::to('img/courses/ekrpriem.png') }}" alt="">

View File

@ -0,0 +1,49 @@
@extends('layouts.applicant-layout')
@section('content')
<style>
.buttonHover {
transition: .3s all;
}
.buttonHover:hover {
background-color: #006147;
transform: scale(1.03);
color: #e0e0e0;
}
</style>
<div class="container my-4">
<div class="row d-flex justify-content-center align-items-center">
@foreach($receptionScreens as $receptionScreen)
<div class="col-8">
<a href="{{ route('web-consultations') }}">
<h4>
<div
class="d-flex justify-content-start align-items-center w-100 h-100 border border-secondary m-1 p-4 buttonHover rounded-2">
{{ $receptionScreen->name }}
</div>
</h4>
</a>
</div>
@foreach($receptionScreen->files as $file)
<div class="col-8">
<a href="{{ $file->url }}">{{ $file->name }}</a>
</div>
@endforeach
@endforeach
<div class="col-8">
<a href="ui-4.html#">
<h4>
<div
class="d-flex justify-content-start align-items-center w-100 h-100 border border-secondary m-1 p-4 buttonHover rounded-2">
Калькулятор ЕГЭ
</div>
</h4>
</a>
</div>
</div>
</div>
@endsection

View File

@ -1,6 +1,7 @@
<?php <?php
use App\Http\Controllers\FileController; use App\Http\Controllers\FileController;
use App\Http\Controllers\PageController;
use App\Http\Controllers\ReceptionScreenController; use App\Http\Controllers\ReceptionScreenController;
use App\Http\Controllers\ProfileController; use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UploadFileController; use App\Http\Controllers\UploadFileController;
@ -56,7 +57,7 @@ Route::get('/training courses', function () {
})->name('podgotovitelnye-kursy'); })->name('podgotovitelnye-kursy');
Route::get('/reception-screens', [PageController::class, 'index'])->name('reception-screens');
Route::get('/web-consultations', function () { Route::get('/web-consultations', function () {

View File

@ -0,0 +1,131 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Tests\TestCase;
class ReceptionScreenTest extends TestCase
{
private User $adminUser;
private User $noAdminUser;
private array $user;
protected function setUp(): void
{
parent::setUp();
$this->user = User::factory()->make()->only([
'name',
'email',
'password'
]);
$this->adminUser = User::factory()->create([
'name' => 'admin',
'email' => 'test@example.com',
'password' => 123456
]);
$this->noAdminUser = User::factory()->create([
'name' => 'noadmin',
'email' => 'notest@example.com',
'password' => 'no123456'
]);
}
public function testUsersPage(): void
{
$response = $this->actingAs($this->adminUser)
->withSession(['banned' => false])
->get(route('users.index'));
$response->assertOk();
}
public function testNoAdminNoSeeUsersPage(): void
{
$response = $this->actingAs($this->noAdminUser)
->withSession(['banned' => false])
->get(route('users.index'));
$response->assertStatus(403);
}
public function testCreateUserPage(): void
{
$response = $this->actingAs($this->adminUser)
->withSession(['banned' => false])
->get(route('users.create'));
$response->assertOk();
}
public function testNoAdminCreateUserPage(): void
{
$response = $this->actingAs($this->noAdminUser)
->withSession(['banned' => false])
->get(route('users.create'));
$response->assertStatus(403);
}
public function testStoreUser(): void
{
$response = $this->actingAs($this->adminUser)
->withSession(['banned' => false])
->post(route('users.store', $this->user));
$response->assertRedirect(route('users.index'));
$this->assertDatabaseHas('users', $this->user);
}
public function testNoAdminNoStoreUser(): void
{
$response = $this->actingAs($this->noAdminUser)
->withSession(['banned' => false])
->post(route('users.store', $this->user));
$response->assertStatus(403);
$this->assertDatabaseMissing('users', $this->user);
}
public function testEditUserPage(): void
{
$response = $this->actingAs($this->adminUser)
->withSession(['banned' => false])
->get(route('users.edit', $this->adminUser));
$response->assertOk();
}
public function testNoAdminEditUserPage(): void
{
$response = $this->actingAs($this->noAdminUser)
->withSession(['banned' => false])
->get(route('users.edit', $this->noAdminUser));
$response->assertStatus(403);
}
public function testUpdateUser(): void
{
$response = $this->actingAs($this->adminUser)
->withSession(['banned' => false])
->patch(route('users.update', $this->noAdminUser), $this->user);
$response->assertRedirect(route('users.index'));
$dataWithOutHashPassword = $this->user;
unset($dataWithOutHashPassword['password']);
$this->assertDatabaseHas('users', $dataWithOutHashPassword);
}
public function testNoAdminNoUpdateUser(): void
{
$response = $this->actingAs($this->noAdminUser)
->withSession(['banned' => false])
->patch(route('users.update', $this->noAdminUser), $this->user);
$response->assertStatus(403);
$noAdminData = $this->noAdminUser->only(['name', 'email', 'password']);
$this->assertDatabaseHas('users', $noAdminData);
$this->assertDatabaseMissing('users', $this->user);
}
}