Compare commits
No commits in common. "2ade2d56960daabec77a69116f22cc07c4dc475b" and "42ac5057c45aecbcc45b2dd2d0386ab752e2ab9b" have entirely different histories.
2ade2d5696
...
42ac5057c4
|
@ -14,7 +14,7 @@ class ReceptionScreenController extends Controller
|
|||
{
|
||||
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'));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ namespace App\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class ReceptionScreen extends Model
|
||||
{
|
||||
|
@ -13,11 +12,8 @@ class ReceptionScreen extends Model
|
|||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'position'
|
||||
'url',
|
||||
'parent',
|
||||
'children'
|
||||
];
|
||||
|
||||
public function files(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\File', 'reception_screen_id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
"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",
|
||||
|
|
|
@ -14,7 +14,6 @@ return new class extends Migration
|
|||
Schema::create('reception_screens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->integer('position');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,13 +11,10 @@ return new class extends Migration
|
|||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
Schema::create('file', 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();
|
||||
});
|
||||
}
|
||||
|
@ -27,6 +24,6 @@ return new class extends Migration
|
|||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
Schema::dropIfExists('file');
|
||||
}
|
||||
};
|
|
@ -21,8 +21,7 @@ class DatabaseSeeder extends Seeder
|
|||
'password' => 123456
|
||||
]);
|
||||
$this->call([
|
||||
ReceptionScreenSeeder::class,
|
||||
FileSeeder::class
|
||||
ReceptionScreenSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -17,17 +17,14 @@ 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(),
|
||||
]
|
||||
]);
|
||||
|
|
|
@ -3,21 +3,9 @@
|
|||
@foreach($onlineDocuments as $onlineDocument)
|
||||
<div>
|
||||
{{ $onlineDocument->name }}
|
||||
{{ $onlineDocument->id }}
|
||||
{{ $onlineDocument->position }}
|
||||
@foreach($onlineDocument->files as $file)
|
||||
<div>
|
||||
{{ $file->name }}
|
||||
{{ $file->url }}
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
{{ $onlineDocument->url }}
|
||||
{{ $onlineDocument->parent }}
|
||||
{{ $onlineDocument->children }}
|
||||
</div>
|
||||
@endforeach
|
||||
@php
|
||||
$files = \App\Models\File::all();
|
||||
foreach ($files as $file) {
|
||||
echo ($file);
|
||||
}
|
||||
@endphp
|
||||
@endsection
|
||||
|
|
|
@ -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(!is_null(Auth::getUser()) && Auth::getUser()->name === 'admin')
|
||||
@if(Auth::getUser()->name === 'admin')
|
||||
<li class="list-group-item"></li>
|
||||
<li class="list-group-item"><a href="{{ route('users.index') }}">Список администраторов</a></li>
|
||||
@endif
|
||||
|
|
Loading…
Reference in New Issue