2022_06_29_180448_create_vLeftmenu_view.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use Illuminate\Support\Facades\DB;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateVLeftmenuView extends Migration
  6. {
  7. public function up()
  8. {
  9. DB::statement("CREATE VIEW `v_leftmenu` AS
  10. SELECT
  11. `funmenu`.`icon` AS `icon`,
  12. `funmenu`.`MenuName` AS `MenuName`,
  13. `funmenu`.`Corder` AS `FunMenuCorder`,
  14. `funmenudetail`.`FunMenuId` AS `FunMenuId`,
  15. `funmenudetail`.`FunId` AS `FunId`,
  16. `functions`.`FunName` AS `FunName`,
  17. `functions`.`FunLink` AS `FunLink`,
  18. `functions`.`FunDesc` AS `FunDesc`,
  19. `functions`.`Valid` AS `Valid`,
  20. `functions`.`created_at` AS `created_at`,
  21. `functions`.`updated_at` AS `updated_at`,
  22. `functions`.`Oid` AS `Oid`,
  23. `funmenudetail`.`Corder` AS FunMenuDetailCOrder
  24. FROM
  25. ((`funmenu`
  26. JOIN funmenudetail ON ((`funmenu`.`id` = `funmenudetail`.`FunMenuId`)))
  27. JOIN functions ON ((`funmenudetail`.`FunId` = `functions`.`id`)))
  28. WHERE
  29. `functions`.`id` IN (SELECT
  30. `Functions_1`.`id`
  31. FROM
  32. functions Functions_1
  33. WHERE
  34. (LOCATE((CONVERT( CONCAT(',', `Functions_1`.`id`, ',') USING UTF8MB3) COLLATE utf8_unicode_ci),
  35. CONVERT( CONCAT(',',
  36. (SELECT
  37. `funusergroups`.`FunList`
  38. FROM
  39. funusergroups
  40. WHERE
  41. (`funusergroups`.`id` = 1)),
  42. ',') USING UTF8MB3)) > 0))
  43. ORDER BY `funmenu`.`Corder` , `funmenudetail`.`Corder`
  44. LIMIT 0 , 1000
  45. ");
  46. }
  47. public function down()
  48. {
  49. DB::statement("DROP VIEW v_leftmenu");
  50. }
  51. }