diff --git a/.editorconfig b/.editorconfig index a186cd2..8f0de65 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,5 +14,5 @@ trim_trailing_whitespace = false [*.{yml,yaml}] indent_size = 2 -[compose.yaml] +[docker-compose.yml] indent_size = 4 diff --git a/Modules/Test/App/Http/Controllers/.gitkeep b/Modules/Test/App/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/App/Http/Controllers/TestController.php b/Modules/Test/App/Http/Controllers/TestController.php new file mode 100644 index 0000000..8a56baa --- /dev/null +++ b/Modules/Test/App/Http/Controllers/TestController.php @@ -0,0 +1,67 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Test', '/routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Test', '/routes/api.php')); + } +} diff --git a/Modules/Test/App/Providers/TestServiceProvider.php b/Modules/Test/App/Providers/TestServiceProvider.php new file mode 100644 index 0000000..4ea9ddf --- /dev/null +++ b/Modules/Test/App/Providers/TestServiceProvider.php @@ -0,0 +1,114 @@ +registerCommands(); + $this->registerCommandSchedules(); + $this->registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/migrations')); + } + + /** + * Register the service provider. + */ + public function register(): void + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register commands in the format of Command::class + */ + protected function registerCommands(): void + { + // $this->commands([]); + } + + /** + * Register command Schedules. + */ + protected function registerCommandSchedules(): void + { + // $this->app->booted(function () { + // $schedule = $this->app->make(Schedule::class); + // $schedule->command('inspire')->hourly(); + // }); + } + + /** + * Register translations. + */ + public function registerTranslations(): void + { + $langPath = resource_path('lang/modules/'.$this->moduleNameLower); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, $this->moduleNameLower); + $this->loadJsonTranslationsFrom($langPath); + } else { + $this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower); + $this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang')); + } + } + + /** + * Register config. + */ + protected function registerConfig(): void + { + $this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config'); + $this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower); + } + + /** + * Register views. + */ + public function registerViews(): void + { + $viewPath = resource_path('views/modules/'.$this->moduleNameLower); + $sourcePath = module_path($this->moduleName, 'resources/views'); + + $this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']); + + $this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower); + + $componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.config('modules.paths.generator.component-class.path')); + Blade::componentNamespace($componentNamespace, $this->moduleNameLower); + } + + /** + * Get the services provided by the provider. + */ + public function provides(): array + { + return []; + } + + private function getPublishableViewPaths(): array + { + $paths = []; + foreach (config('view.paths') as $path) { + if (is_dir($path.'/modules/'.$this->moduleNameLower)) { + $paths[] = $path.'/modules/'.$this->moduleNameLower; + } + } + + return $paths; + } +} diff --git a/Modules/Test/Database/Seeders/.gitkeep b/Modules/Test/Database/Seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/Database/Seeders/TestDatabaseSeeder.php b/Modules/Test/Database/Seeders/TestDatabaseSeeder.php new file mode 100644 index 0000000..fc898bb --- /dev/null +++ b/Modules/Test/Database/Seeders/TestDatabaseSeeder.php @@ -0,0 +1,16 @@ +call([]); + } +} diff --git a/Modules/Test/composer.json b/Modules/Test/composer.json new file mode 100644 index 0000000..c8f0da0 --- /dev/null +++ b/Modules/Test/composer.json @@ -0,0 +1,31 @@ +{ + "name": "nwidart/test", + "description": "", + "authors": [ + { + "name": "Nicolas Widart", + "email": "n.widart@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [], + "aliases": { + + } + } + }, + "autoload": { + "psr-4": { + "Modules\\Test\\": "", + "Modules\\Test\\App\\": "app/", + "Modules\\Test\\Database\\Factories\\": "database/factories/", + "Modules\\Test\\Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Modules\\Test\\Tests\\": "tests/" + } + } +} diff --git a/Modules/Test/config/.gitkeep b/Modules/Test/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/config/config.php b/Modules/Test/config/config.php new file mode 100644 index 0000000..a054070 --- /dev/null +++ b/Modules/Test/config/config.php @@ -0,0 +1,5 @@ + 'Test', +]; diff --git a/Modules/Test/module.json b/Modules/Test/module.json new file mode 100644 index 0000000..d5dff7d --- /dev/null +++ b/Modules/Test/module.json @@ -0,0 +1,11 @@ +{ + "name": "Test", + "alias": "test", + "description": "", + "keywords": [], + "priority": 0, + "providers": [ + "Modules\\Test\\App\\Providers\\TestServiceProvider" + ], + "files": [] +} diff --git a/Modules/Test/package.json b/Modules/Test/package.json new file mode 100644 index 0000000..d6fbfc8 --- /dev/null +++ b/Modules/Test/package.json @@ -0,0 +1,15 @@ +{ + "private": true, + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "axios": "^1.1.2", + "laravel-vite-plugin": "^0.7.5", + "sass": "^1.69.5", + "postcss": "^8.3.7", + "vite": "^4.0.0" + } +} diff --git a/Modules/Test/resources/assets/js/app.js b/Modules/Test/resources/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/resources/assets/sass/app.scss b/Modules/Test/resources/assets/sass/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/resources/views/.gitkeep b/Modules/Test/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Modules/Test/resources/views/index.blade.php b/Modules/Test/resources/views/index.blade.php new file mode 100644 index 0000000..a34a6f4 --- /dev/null +++ b/Modules/Test/resources/views/index.blade.php @@ -0,0 +1,7 @@ +@extends('test::layouts.master') + +@section('content') +
Module: {!! config('test.name') !!}
+@endsection diff --git a/Modules/Test/resources/views/layouts/master.blade.php b/Modules/Test/resources/views/layouts/master.blade.php new file mode 100644 index 0000000..0f18a22 --- /dev/null +++ b/Modules/Test/resources/views/layouts/master.blade.php @@ -0,0 +1,29 @@ + + + + + + + + + +'; var_dump($accessListData->toArray()); echo''; + } else { + var_dump($accessListModel::all()); + } + + } + + public function postAccess(Request $rqst) + { + $accessListModel = new AccessModel(); + $accessListModel->role = $rqst['role']; + $accessListModel->title = $rqst['title']; + $accessListModel->save(); + } + + public function delAccess($id) + { + $accessListModel = new AccessModel(); + //$accessListModel::where(['access_id' => $id])->delete(); + $accessListModel::destroy($id); + } +} diff --git a/app/Http/Controllers/TestController.php b/app/Http/Controllers/TestController.php new file mode 100644 index 0000000..4aa3bb1 --- /dev/null +++ b/app/Http/Controllers/TestController.php @@ -0,0 +1,53 @@ +table('arch_lk_access_list')->select(['*'])->get(); + return view('roles', ['roles' => $roles]); + } + + + public function getAccess($id) + { + $roles = DB::connection('mysql')->table('arch_lk_access_list')->select(['*'])->where('access_id', '=', $id)->get(); + $response = new Response(json_encode($roles[0])); + $response->header('Content-type', 'text/plain'); + $response->header('Access-Control-Allow-Methods', 'POST'); + + return $response; + } + + + public function redirect() + { + // return redirect()->away('https://google.com'); + //return redirect()->action([TestController::class, 'getAccess'], ['id' => 3]); + return redirect()->route('getAccessById', ['id' => 2]); + } + + public function getParam(Request $rqst) + { + //echo '
'; var_dump($rqst->cookie('test_cookie')); echo'';
+ //return response('test')->cookie('test_cookie', $rqst->id);
+ }
+
+ public function setRole(Request $rqst)
+ {
+ $lastInsert = DB::connection('mysql')->table('arch_lk_access_list')->insertGetId(['role' => $rqst->roleName, 'title' => $rqst->roleTitle]);
+ return redirect()->route('get_role');
+ }
+
+ public function delRole(Request $rqst)
+ {
+ $lastInsert = DB::connection('mysql')->table('arch_lk_access_list')->where('access_id', '=', $rqst->access_id)->delete();
+ return redirect()->route('get_role');
+ }
+}
diff --git a/app/Http/Controllers/TestDataController.php b/app/Http/Controllers/TestDataController.php
new file mode 100644
index 0000000..76cb7eb
--- /dev/null
+++ b/app/Http/Controllers/TestDataController.php
@@ -0,0 +1,19 @@
+test_int = $rqst->int;
+ $model->test_char = $rqst->char;
+
+ $model->save();
+ }
+
+}
diff --git a/app/Http/Controllers/TestFormController.php b/app/Http/Controllers/TestFormController.php
new file mode 100644
index 0000000..0cda314
--- /dev/null
+++ b/app/Http/Controllers/TestFormController.php
@@ -0,0 +1,25 @@
+first_name = $rqst->first_name;
+ $testTable->last_name = $rqst->last_name;
+ $testTable->department_name = $rqst->department_name;
+ $testTable->save();
+
+ return redirect('/test_table');
+ }
+}
diff --git a/app/Models/AccessModel.php b/app/Models/AccessModel.php
new file mode 100644
index 0000000..3f33b06
--- /dev/null
+++ b/app/Models/AccessModel.php
@@ -0,0 +1,17 @@
+
+ */
+ protected $policies = [
+ //
+ ];
+
+ /**
+ * Register any authentication / authorization services.
+ */
+ public function boot(): void
+ {
+ //
+ }
+}
diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php
new file mode 100644
index 0000000..2be04f5
--- /dev/null
+++ b/app/Providers/BroadcastServiceProvider.php
@@ -0,0 +1,19 @@
+>
+ */
+ protected $listen = [
+ Registered::class => [
+ SendEmailVerificationNotification::class,
+ ],
+ ];
+
+ /**
+ * Register any events for your application.
+ */
+ public function boot(): void
+ {
+ //
+ }
+
+ /**
+ * Determine if events and listeners should be automatically discovered.
+ */
+ public function shouldDiscoverEvents(): bool
+ {
+ return false;
+ }
+}
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 6b901f8..a9f4519 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -2,24 +2,21 @@
namespace Database\Seeders;
-use App\Models\User;
-use Illuminate\Database\Console\Seeds\WithoutModelEvents;
+// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
- use WithoutModelEvents;
-
/**
* Seed the application's database.
*/
public function run(): void
{
- // User::factory(10)->create();
+ // \App\Models\User::factory(10)->create();
- User::factory()->create([
- 'name' => 'Test User',
- 'email' => 'test@example.com',
- ]);
+ // \App\Models\User::factory()->create([
+ // 'name' => 'Test User',
+ // 'email' => 'test@example.com',
+ // ]);
}
}
diff --git a/phpunit.xml b/phpunit.xml
index d703241..bc86714 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -19,17 +19,14 @@
{{ $roleData }}
+ + + + + + + diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php new file mode 100644 index 0000000..e474bd7 --- /dev/null +++ b/resources/views/app.blade.php @@ -0,0 +1,16 @@ + + + + + +| id роли | +имя роли | +заголовок роли | +удалить | +
|---|---|---|---|
| {{ $role->access_id }} | +{{ $role->role }} | +{{ $role->title }} | ++ + | +