Compare commits

..

No commits in common. "2ade2d56960daabec77a69116f22cc07c4dc475b" and "42ac5057c45aecbcc45b2dd2d0386ab752e2ab9b" have entirely different histories.

11 changed files with 12 additions and 107 deletions

View File

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

View File

@ -1,24 +0,0 @@
<?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,7 +4,6 @@ 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 ReceptionScreen extends Model class ReceptionScreen extends Model
{ {
@ -13,11 +12,8 @@ class ReceptionScreen extends Model
protected $fillable = [ protected $fillable = [
'id', 'id',
'name', 'name',
'position' 'url',
'parent',
'children'
]; ];
public function files(): HasMany
{
return $this->hasMany('App\Models\File', 'reception_screen_id');
}
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,7 +51,7 @@
<ul> <ul>
<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>
<li class="list-group-item"><a href="">Дни открытых дверей</a></li> <li class="list-group-item"><a href="">Дни открытых дверей</a></li>
@if(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin') @if(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>
@endif @endif