From 2747792221dc48202814e5f22caedd65bef39020 Mon Sep 17 00:00:00 2001 From: johny Date: Thu, 19 Dec 2024 11:45:31 +0200 Subject: [PATCH] init --- .gitignore | 1 + README.md | 1 + composer.json | 28 ++++++++++++ src/Console/Commands/PostCommand.php | 44 +++++++++++++++++++ src/Controllers/Controller.php | 8 ++++ src/Controllers/PostController.php | 15 +++++++ src/Models/Post.php | 15 +++++++ src/Providers/PostServiceProvider.php | 40 +++++++++++++++++ .../2024_12_19_072507_create_posts_table.php | 28 ++++++++++++ src/resources/views/index.blade.php | 17 +++++++ src/routes/web.php | 6 +++ 11 files changed, 203 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 composer.json create mode 100644 src/Console/Commands/PostCommand.php create mode 100644 src/Controllers/Controller.php create mode 100644 src/Controllers/PostController.php create mode 100644 src/Models/Post.php create mode 100644 src/Providers/PostServiceProvider.php create mode 100644 src/database/migrations/2024_12_19_072507_create_posts_table.php create mode 100644 src/resources/views/index.blade.php create mode 100644 src/routes/web.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..22d0d82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e0a7fb --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Posts diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..117dfef --- /dev/null +++ b/composer.json @@ -0,0 +1,28 @@ +{ + "name": "batenko1/posts", + "description": "description", + "minimum-stability": "stable", + "license": "MIT", + "authors": [ + { + "name": "batenko1", + "email": "batenko4@gmail.com" + } + ], + "require": { + "php": "^8.2" + }, + "extra": { + "laravel": { + "providers": [ + "Batenko1\\Posts\\Providers\\PostServiceProdiver" + ] + } + }, + "autoload": { + "psr-4": { + "Batenko1\\Posts\\": "src" + } + } +} + diff --git a/src/Console/Commands/PostCommand.php b/src/Console/Commands/PostCommand.php new file mode 100644 index 0000000..534585d --- /dev/null +++ b/src/Console/Commands/PostCommand.php @@ -0,0 +1,44 @@ +ask('Начать установку? (да/нет)'); + + if (strtolower($ask) === 'да') { + $this->info('Установка началась...'); + // Ваш код для выполнения установки + } else { + $this->warn('Установка отменена.'); + } + + } +} diff --git a/src/Controllers/Controller.php b/src/Controllers/Controller.php new file mode 100644 index 0000000..cde3000 --- /dev/null +++ b/src/Controllers/Controller.php @@ -0,0 +1,8 @@ +get(); + + return view('posts::index', compact('posts')); + } +} diff --git a/src/Models/Post.php b/src/Models/Post.php new file mode 100644 index 0000000..382d220 --- /dev/null +++ b/src/Models/Post.php @@ -0,0 +1,15 @@ +loadRoutesFrom(__DIR__.'/../routes/web.php'); + $this->loadViewsFrom(__DIR__.'/../resources/views', 'posts'); + + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + + + $this->publishes([ + __DIR__.'/../resources/views' => resource_path('views/vendor/posts'), + ]); + + if($this->app->runningInConsole()) { + $this->commands([ + PostCommand::class + ]); + } + + } +} diff --git a/src/database/migrations/2024_12_19_072507_create_posts_table.php b/src/database/migrations/2024_12_19_072507_create_posts_table.php new file mode 100644 index 0000000..e08090e --- /dev/null +++ b/src/database/migrations/2024_12_19_072507_create_posts_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('title'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('posts'); + } +}; diff --git a/src/resources/views/index.blade.php b/src/resources/views/index.blade.php new file mode 100644 index 0000000..1987a26 --- /dev/null +++ b/src/resources/views/index.blade.php @@ -0,0 +1,17 @@ + + + + + + + Document + + +@foreach($posts as $post) + + {{ $post->id }}.{{ $post->title }}
+ +@endforeach + + diff --git a/src/routes/web.php b/src/routes/web.php new file mode 100644 index 0000000..edbe008 --- /dev/null +++ b/src/routes/web.php @@ -0,0 +1,6 @@ +