From 04cb20e7a1920f1f95e1683d38147375bcf993bf Mon Sep 17 00:00:00 2001 From: aslan Date: Fri, 19 Jan 2024 10:48:00 +0300 Subject: [PATCH] add documents online resource --- .../Controllers/DocumentsOnlineController.php | 65 ++++++++++++++++++ .../Requests/StoreDocumentsOnlineRequest.php | 28 ++++++++ .../Requests/UpdateDocumentsOnlineRequest.php | 28 ++++++++ app/Models/DocumentsOnline.php | 19 ++++++ app/Policies/DocumentsOnlinePolicy.php | 66 +++++++++++++++++++ database/factories/DocumentsOnlineFactory.php | 23 +++++++ ...8_082251_create_documents_online_table.php | 31 +++++++++ database/seeders/DatabaseSeeder.php | 7 +- database/seeders/DocumentsOnlineSeeder.php | 41 ++++++++++++ .../views/documents-online/index.blade.php | 8 +++ routes/web.php | 8 ++- 11 files changed, 320 insertions(+), 4 deletions(-) create mode 100644 app/Http/Controllers/DocumentsOnlineController.php create mode 100644 app/Http/Requests/StoreDocumentsOnlineRequest.php create mode 100644 app/Http/Requests/UpdateDocumentsOnlineRequest.php create mode 100644 app/Models/DocumentsOnline.php create mode 100644 app/Policies/DocumentsOnlinePolicy.php create mode 100644 database/factories/DocumentsOnlineFactory.php create mode 100644 database/migrations/2024_01_18_082251_create_documents_online_table.php create mode 100644 database/seeders/DocumentsOnlineSeeder.php create mode 100644 resources/views/documents-online/index.blade.php diff --git a/app/Http/Controllers/DocumentsOnlineController.php b/app/Http/Controllers/DocumentsOnlineController.php new file mode 100644 index 0000000..b1668be --- /dev/null +++ b/app/Http/Controllers/DocumentsOnlineController.php @@ -0,0 +1,65 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Http/Requests/UpdateDocumentsOnlineRequest.php b/app/Http/Requests/UpdateDocumentsOnlineRequest.php new file mode 100644 index 0000000..457f078 --- /dev/null +++ b/app/Http/Requests/UpdateDocumentsOnlineRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + // + ]; + } +} diff --git a/app/Models/DocumentsOnline.php b/app/Models/DocumentsOnline.php new file mode 100644 index 0000000..16ca5ec --- /dev/null +++ b/app/Models/DocumentsOnline.php @@ -0,0 +1,19 @@ + + */ +class DocumentsOnlineFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2024_01_18_082251_create_documents_online_table.php b/database/migrations/2024_01_18_082251_create_documents_online_table.php new file mode 100644 index 0000000..b8f92e5 --- /dev/null +++ b/database/migrations/2024_01_18_082251_create_documents_online_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('name'); + $table->string('url'); + $table->string('parent'); + $table->string('children'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('documents_online'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index e12434e..4b2af79 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,12 +13,15 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - \App\Models\User::factory(10)->create(); + User::factory(10)->create(); - \App\Models\User::factory()->create([ + User::factory()->create([ 'name' => 'admin', 'email' => 'test@example.com', 'password' => 123456 ]); +// $this->call([ +// DocumentsOnlineSeeder::class +// ]); } } diff --git a/database/seeders/DocumentsOnlineSeeder.php b/database/seeders/DocumentsOnlineSeeder.php new file mode 100644 index 0000000..70c055b --- /dev/null +++ b/database/seeders/DocumentsOnlineSeeder.php @@ -0,0 +1,41 @@ +insert([ + [ + 'name' => 'Подать документы онлайн', + 'url' => '', + 'parent' => '0', + 'children' => '2/3', + 'created_at' => Carbon::now(), + ], + [ + 'name' => 'По образовательным программам высшего образования', + 'url' => '', + 'parent' => '1', + 'children' => '', + 'created_at' => Carbon::now(), + ], + [ + 'name' => 'По образовательным программам среднего профессионального образования (колледж)', + 'url' => '', + 'parent' => '1', + 'children' => '', + 'created_at' => Carbon::now(), + ] + ]); + } +} diff --git a/resources/views/documents-online/index.blade.php b/resources/views/documents-online/index.blade.php new file mode 100644 index 0000000..b4b4101 --- /dev/null +++ b/resources/views/documents-online/index.blade.php @@ -0,0 +1,8 @@ +@extends('layouts.admin-layout') +@section('content') + @foreach($documentsOnline as $documentOnline) + {{ $documentOnline->name }} + {{ $documentOnline->url }} + {{ $documentOnline->description }} + @endforeach +@endsection diff --git a/routes/web.php b/routes/web.php index 2b079c9..fc2e08f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,6 @@ name('home'); -Route::resource('/users', UserController::class); +Route::resources([ + '/users' => UserController::class, + '/documents-online' => DocumentsOnlineController::class +]); Route::get('/course', function () { return view('pages.course'); @@ -33,7 +37,7 @@ Route::get('/abitur', function () { Route::post('/uploadfile', [UploadFileController::class, 'showUploadFile'])->name('uploadfile'); Route::get('/dashboard', function () { - return view('dashboard'); + return view('admin'); })->middleware(['auth', 'verified'])->name('dashboard'); Route::middleware('auth')->group(function () {