Compare commits
2 Commits
42ac5057c4
...
2ade2d5696
Author | SHA1 | Date |
---|---|---|
aslan | 2ade2d5696 | |
aslan | e6d7e8bf9e |
|
@ -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();
|
$onlineDocuments = ReceptionScreen::all()->sortBy('position');
|
||||||
return view('admin-reception-screen.index', compact('onlineDocuments'));
|
return view('admin-reception-screen.index', compact('onlineDocuments'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ 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
|
||||||
{
|
{
|
||||||
|
@ -12,8 +13,11 @@ class ReceptionScreen extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'url',
|
'position'
|
||||||
'parent',
|
|
||||||
'children'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function files(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\File', 'reception_screen_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
"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": ["laravel", "framework"],
|
"keywords": [
|
||||||
|
"laravel",
|
||||||
|
"framework"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
|
|
@ -14,6 +14,7 @@ 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,13 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::create('file', function (Blueprint $table) {
|
Schema::create('files', 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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -24,6 +27,6 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('file');
|
Schema::dropIfExists('files');
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -21,7 +21,8 @@ class DatabaseSeeder extends Seeder
|
||||||
'password' => 123456
|
'password' => 123456
|
||||||
]);
|
]);
|
||||||
$this->call([
|
$this->call([
|
||||||
ReceptionScreenSeeder::class
|
ReceptionScreenSeeder::class,
|
||||||
|
FileSeeder::class
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(),
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,14 +17,17 @@ 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(),
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -3,9 +3,21 @@
|
||||||
@foreach($onlineDocuments as $onlineDocument)
|
@foreach($onlineDocuments as $onlineDocument)
|
||||||
<div>
|
<div>
|
||||||
{{ $onlineDocument->name }}
|
{{ $onlineDocument->name }}
|
||||||
{{ $onlineDocument->url }}
|
{{ $onlineDocument->id }}
|
||||||
{{ $onlineDocument->parent }}
|
{{ $onlineDocument->position }}
|
||||||
{{ $onlineDocument->children }}
|
@foreach($onlineDocument->files as $file)
|
||||||
|
<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
|
||||||
|
|
|
@ -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(Auth::getUser()->name === 'admin')
|
@if(!is_null(Auth::getUser()) && 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
|
||||||
|
|
Loading…
Reference in New Issue