Compare commits

...

2 Commits

Author SHA1 Message Date
aslan 2ade2d5696 composer lint fix
Tests & Lint & Deploy to Railway / build (20.x, 8.2) (push) Successful in 1m58s Details
Tests & Lint & Deploy to Railway / deploy (8.1) (push) Failing after 1m19s Details
2024-01-23 18:03:26 +03:00
aslan e6d7e8bf9e add files for ReceptionScreen 2024-01-23 17:58:48 +03:00
11 changed files with 107 additions and 12 deletions

View File

@ -14,7 +14,7 @@ class ReceptionScreenController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$onlineDocuments = ReceptionScreen::all();
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
return view('admin-reception-screen.index', compact('onlineDocuments'));
}

24
app/Models/File.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class File extends Model
{
use HasFactory;
protected $fillable = [
'id',
'name',
'url',
'description'
];
public function receptionScreen(): BelongsTo
{
return $this->belongsTo(ReceptionScreen::class);
}
}

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ReceptionScreen extends Model
{
@ -12,8 +13,11 @@ class ReceptionScreen extends Model
protected $fillable = [
'id',
'name',
'url',
'parent',
'children'
'position'
];
public function files(): HasMany
{
return $this->hasMany('App\Models\File', 'reception_screen_id');
}
}

View File

@ -2,7 +2,10 @@
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"keywords": [
"laravel",
"framework"
],
"license": "MIT",
"require": {
"php": "^8.2",

View File

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('reception_screens', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('position');
$table->timestamps();
});
}

View File

@ -11,10 +11,13 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('file', function (Blueprint $table) {
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description');
$table->string('url');
$table->integer('position');
$table->foreignId('reception_screen_id')->constrained('reception_screens');
$table->timestamps();
});
}
@ -24,6 +27,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('file');
Schema::dropIfExists('files');
}
};

View File

@ -21,7 +21,8 @@ class DatabaseSeeder extends Seeder
'password' => 123456
]);
$this->call([
ReceptionScreenSeeder::class
ReceptionScreenSeeder::class,
FileSeeder::class
]);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class FileSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('files')->insert([
[
'name' => 'файл 1',
'description' => 'description1',
'url' => 'url/url1',
'position' => 2,
'reception_screen_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'файл 2',
'description' => 'description2',
'url' => 'url/url2',
'position' => 3,
'reception_screen_id' => 1,
'created_at' => Carbon::now(),
],
[
'name' => 'файл 3',
'description' => 'description3',
'url' => 'url/url3',
'reception_screen_id' => 1,
'position' => 1,
'created_at' => Carbon::now(),
]
]);
}
}

View File

@ -17,14 +17,17 @@ class ReceptionScreenSeeder extends Seeder
DB::table('reception_screens')->insert([
[
'name' => 'Пункт 1 с файлами',
'position' => 2,
'created_at' => Carbon::now(),
],
[
'name' => 'Пункт 2 с файлами',
'position' => 3,
'created_at' => Carbon::now(),
],
[
'name' => 'Пункт 3 с файлами',
'position' => 1,
'created_at' => Carbon::now(),
]
]);

View File

@ -3,9 +3,21 @@
@foreach($onlineDocuments as $onlineDocument)
<div>
{{ $onlineDocument->name }}
{{ $onlineDocument->url }}
{{ $onlineDocument->parent }}
{{ $onlineDocument->children }}
{{ $onlineDocument->id }}
{{ $onlineDocument->position }}
@foreach($onlineDocument->files as $file)
<div>
{{ $file->name }}
{{ $file->url }}
</div>
@endforeach
</div>
@endforeach
@php
$files = \App\Models\File::all();
foreach ($files as $file) {
echo ($file);
}
@endphp
@endsection

View File

@ -51,7 +51,7 @@
<ul>
<li class="list-group-item"><a href="{{ route('admin-reception-screen.index') }}">Экран Приема</a></li>
<li class="list-group-item"><a href="">Дни открытых дверей</a></li>
@if(Auth::getUser()->name === 'admin')
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
<li class="list-group-item"></li>
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
@endif