forked from aslan/applicant-site
add files for ReceptionScreen
This commit is contained in:
parent
42ac5057c4
commit
e6d7e8bf9e
|
@ -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'));
|
||||
}
|
||||
|
||||
|
|
|
@ -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\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');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
};
|
|
@ -21,7 +21,8 @@ class DatabaseSeeder extends Seeder
|
|||
'password' => 123456
|
||||
]);
|
||||
$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([
|
||||
[
|
||||
'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,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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue