added a feature to populate the user group matrix
This commit is contained in:
parent
265d1c7f97
commit
e220cde5da
46
php_code/app/Console/Commands/PopulateTableFromSql.php
Normal file
46
php_code/app/Console/Commands/PopulateTableFromSql.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class PopulateTableFromSql extends Command
|
||||
{
|
||||
protected $signature = 'sql:populate {file} {--connection=}';
|
||||
protected $description = 'Populate tables from a SQL file';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$file = $this->argument('file');
|
||||
$path = base_path($file);
|
||||
//$path = File::path($file);
|
||||
|
||||
if (!File::exists($path)) {
|
||||
$this->error("SQL file not found: {$path}");
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$sql = File::get($path);
|
||||
|
||||
|
||||
|
||||
|
||||
$connection = $this->option('connection') ?: config('database.default');
|
||||
$pdo = DB::connection($connection)->getPdo();
|
||||
|
||||
// Naive split; works for many simple SQL files. For complex dumps,
|
||||
// consider using a DB-specific import (Option B).
|
||||
$statements = array_filter(array_map('trim', preg_split('/;\s*[\r\n]+/', $sql)));
|
||||
|
||||
foreach ($statements as $stmt) {
|
||||
if ($stmt !== '') {
|
||||
$pdo->exec($stmt);
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('SQL import complete.');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
18
php_code/database/user_group.sql
Normal file
18
php_code/database/user_group.sql
Normal file
@ -0,0 +1,18 @@
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (1, NULL, 1, 1, 'LUSPA National', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (1, NULL, 1, 2, 'LUSPA Regional', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 3, 'District Chief Executive', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 4, 'District Coordinating Director', 0, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (1, NULL, 0, 5, 'District MIS', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (1, NULL, 1, 6, 'Head of Physical Planning Department', 1, 1, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 1, 7, 'Development Planning Officer', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 1, 8, 'Head of Works Department', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 1, 9, 'Head of the Roads Unit or Urban Roads Department', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 1, 10, 'District Fire Officer', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 11, 'District Disaster Prevention Department', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 12, 'Head of District Health Department', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 13, 'Representative of the Lands Commission', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 14, 'Representative of the Environmental Protection Agency', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 15, 'Rep from Traditional Council', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 16, 'Chairman of the Works Sub Committee', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 17, 'Chairman of Development Sub Planning Committee', 1, 0, NULL, 1);
|
||||
insert into `user_group_matrices` (`admin_gui`, `created_at`, `drawing_tools`, `id`, `name`, `permit_tools_backend`, `update_permits`, `updated_at`, `view_drawing_tools`) values (0, NULL, 0, 18, '2 Nominated Elected Assembly Members', 1, 0, NULL, 1);
|
||||
@ -77,3 +77,5 @@ add_header Content-Security-Policy "frame-ancestors 'self' https://lupmis.houseb
|
||||
}
|
||||
|
||||
php artisan make:model UserGroupMatrix -m
|
||||
|
||||
php artisan sql:populate database/user_group.sql
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user