migrations/Version20240304042926.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20240304042926 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $entries = [
  19.             [ 
  20.                 'title' => 'Listing'
  21.                 'slug' => 'app_supplier_type'
  22.                 'route' => '/supplier-type/index'
  23.                 'group' => 'Supplier Types'
  24.                 'desc' => 'description',
  25.                 'status' => '1'
  26.             ],
  27.             [ 
  28.                 'title' => 'Add'
  29.                 'slug' => 'app_supplier_type_add'
  30.                 'route' => '/supplier-type/create'
  31.                 'group' => 'Supplier Types'
  32.                 'desc' => 'description',
  33.                 'status' => '1'
  34.             ],
  35.             [ 
  36.                 'title' => 'Edit'
  37.                 'slug' => 'app_supplier_type_edit'
  38.                 'route' => '/supplier-type/edit/*'
  39.                 'group' => 'Supplier Types'
  40.                 'desc' => 'description',
  41.                 'status' => '1'
  42.             ],
  43.             [ 
  44.                 'title' => 'Delete'
  45.                 'slug' => 'app_supplier_type_delete'
  46.                 'route' => '/supplier-type/delete/*'
  47.                 'group' => 'Supplier Types'
  48.                 'desc' => 'description',
  49.                 'status' => '1'
  50.             ],
  51.             
  52.         ];
  53.         foreach ($entries as $entry) {
  54.             $existingEntry $this->connection->fetchAssociative(
  55.                 'SELECT * FROM permissions WHERE permission_slug = :slug',
  56.                 ['slug' => $entry['slug']]
  57.             );
  58.             if (!$existingEntry) {
  59.                 $this->addSql('INSERT INTO permissions (permission_title, permission_slug , permission_route,permission_group,permission_description,status,created_at) VALUES (:title, :slug, :route, :group,:desc,:status,CURRENT_TIMESTAMP)', [
  60.                     'title' => $entry['title'],
  61.                     'slug' => $entry['slug'],
  62.                     'route' => $entry['route'],
  63.                     'group' => $entry['group'],
  64.                     'desc' => $entry['desc'],
  65.                     'status' => 1,
  66.                 ]);
  67.             }
  68.         }
  69.     }
  70.     public function down(Schema $schema): void
  71.     {
  72.         // this down() migration is auto-generated, please modify it to your needs
  73.     }
  74. }