Guest User

Конфиг моделек

a guest
Jul 21st, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.78 KB | None | 0 0
  1. <?php
  2. return [
  3.     'login' => [
  4.         'rules' => [
  5.             'default' => [
  6.                 'login' => [['string', 'minlen'=>5, 'maxlen'=>64]],
  7.                 'password' => [['string', 'minlen'=>5, 'maxlen'=>64]],
  8.             ],
  9.         ],
  10.     ],
  11.     'search' => [
  12.         'rules' => [
  13.             'default' => [
  14.                 'q' =>['string'],                
  15.             ],
  16.         ],
  17.     ],
  18.     'contact' => [
  19.         'rules' => [
  20.             'default' => [
  21.                 'name' =>[['string', 'maxlen'=>64], ['default', 'value'=>'Имя НЕ указано']],
  22.                 'email' =>['email','required'],
  23.                 'phone' =>[['string', 'maxlen'=>64], ['default', 'value'=>'Телефон НЕ указан']],
  24.                 'subject' =>[['string', 'maxlen'=>64],'required'],
  25.                 'message' =>[['string', 'minlen'=>10],'required','text'],
  26.             ],
  27.         ],
  28.     ],
  29.  
  30.    
  31.    
  32.     // TRASH...
  33.     'trash' => [
  34.         'class' => 'page',
  35.         'rules' => [
  36.             'default' => [
  37.                 'id' => ['int'],
  38.                 'sort' => ['int'],
  39.                 'type' => ['string'],
  40.                 'subtype' => ['string'],
  41.                 'created' => ['int','timeCreate'],
  42.                 'updated' => ['int','timeUpdate'],
  43.                 'trash' => ['boolean'],
  44.                 'slug' => [['slug','field'=>'title'],['string', 'maxlen'=>120],['unique','fields'=>['parent_id']]],
  45.                 'title' => [['string', 'maxlen'=>120],'required',['unique','fields'=>['parent_id']]],
  46.             ],
  47.         ],
  48.         'box' => [
  49.             'table' => 'page',
  50.             'where' =>[['trash'=>1]],
  51.             'order' => 'sort',
  52.         ],
  53.     ],
  54.    
  55.    
  56.     // Страницы
  57.     'article' => [
  58.         'class' => 'page',
  59.         'rules' => [
  60.             'search' => [
  61.                 'title' => [['string', 'maxlen'=>120]],
  62.                 'article' => [['string', 'maxlen'=>60000]],
  63.             ],
  64.             'default' => [
  65.                 'id' => ['int'],
  66.                 'sort' => ['int'],
  67.                 'parent_id' => [
  68.                     'int',
  69.                     ['select', 'box'=>'page', 'valueField'=>'id', 'descField'=>'breadtitle'],
  70.                     ['defaultSave','value'=>1], // index
  71.                 ],
  72.                 'type' => ['string',['defaultSave','value'=>'article']],
  73.                 'subtype' => ['string','unique','required'],
  74.                 'created' => ['int','timeCreate'],
  75.                 'updated' => ['int','timeUpdate'],
  76.                 'trash' => ['boolean'],
  77.                 'folder' => ['hidden'],
  78.                 'slug' => [['copy','field'=>'subtype'],'unique'],
  79.                 'title' => [['string', 'maxlen'=>120],'required',['unique','fields'=>['parent_id']]],
  80.                 'metatitle' => [['string', 'maxlen'=>120],['defaultCopy','field'=>'title']],
  81.                 'breadtitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  82.                 'menutitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  83.                 'article' => [['article', 'maxlen'=>60000]],
  84.                 'preview' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  85.                 'metadesc' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  86.             ],
  87.         ],
  88.         'relations' => [
  89.             'parent'=> [
  90.                 'boxName'=> 'page',
  91.                 'type'=>'one',
  92.                 'modelField' => 'parent_id',
  93.                 'boxField' => 'id',
  94.             ],
  95.             'childs'=> [
  96.                 'boxName'=> 'page',
  97.                 'type'=>'many',
  98.                 'modelField' => 'id',
  99.                 'boxField' => 'parent_id',
  100.             ],
  101.         ],
  102.         'box' => [
  103.             'table' => 'page',
  104.             'where' =>[['type'=>'article','trash'=>0]],
  105.             'order' => 'sort',
  106.         ],
  107.     ],
  108.     // Производители
  109.     'manuf' => [
  110.         'class' => 'page',
  111.         'rules' => [
  112.             'search' => [
  113.                 'title' => [['string', 'maxlen'=>120]],
  114.                 'article' => [['string', 'maxlen'=>60000]],
  115.             ],
  116.             'default' => [
  117.                 'id' => ['int'],
  118.                 'sort' => ['int'],
  119.                 'parent_id' => ['int',['defaultSave','value'=>49]], // manufList
  120.                 'type' => ['string',['defaultSave','value'=>'manuf']],
  121.                 'created' => ['int','timeCreate'],
  122.                 'updated' => ['int','timeUpdate'],
  123.                 'trash' => ['boolean'],
  124.                 'folder' => ['hidden'],
  125.                 'thumb' => [['string', 'maxlen'=>120],'img'],
  126.                 'slug' => [['slug','field'=>'title'],['string', 'maxlen'=>120],['unique','fields'=>['parent_id']]],
  127.                 'title' => [['string', 'maxlen'=>120],'required',['unique','fields'=>['parent_id']]],
  128.                 'metatitle' => [['string', 'maxlen'=>120],['defaultCopy','field'=>'title']],
  129.                 'breadtitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  130.                 'menutitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  131.                 'article' => [['article', 'maxlen'=>60000]],
  132.                 'preview' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  133.                 'metadesc' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  134.             ],
  135.         ],
  136.         'relations' => [
  137.             'parent'=> [
  138.                 'boxName'=> 'page',
  139.                 'type'=>'one',
  140.                 'modelField' => 'parent_id',
  141.                 'boxField' => 'id',
  142.             ],
  143.             'products'=> [
  144.                 'boxName'=> 'product',
  145.                 'type'=>'many',
  146.                 'modelField' => 'id',
  147.                 'boxField' => 'manuf_id',
  148.             ],
  149.         ],
  150.         'box' => [
  151.             'table' => 'page',
  152.             'where' =>[['type'=>'manuf','trash'=>0]],
  153.             'order' => 'sort',
  154.         ],
  155.     ],
  156.     // Товары
  157.     'product' => [
  158.         'class' => 'page',
  159.         'rules' => [
  160.             'search' => [
  161.                 'title' => [['string', 'maxlen'=>120]],
  162.                 'article' => [['string', 'maxlen'=>60000]],
  163.                 'manuf_id' =>['int',['select', 'box'=>'manuf', 'valueField'=>'id', 'descField'=>'breadtitle']],
  164.                 'category_id' => ['int',['select', 'box'=>'category', 'valueField'=>'id', 'descField'=>'breadtitle']],
  165.             ],
  166.             'default' => [
  167.                 'id' => ['int'],
  168.                 'sort' => ['int'],
  169.                 'parent_id' => ['int',['copy','field'=>'category_id']],
  170.                 'type' => ['string',['defaultSave','value'=>'product']],
  171.                 'created' => ['int','timeCreate'],
  172.                 'updated' => ['int','timeUpdate'],
  173.                 'trash' => ['boolean'],
  174.                 'topsale' => ['boolean'],
  175.                 'action' => ['boolean'],
  176.                 'newproduct' => ['boolean'],
  177.                 'manuf_id' =>['int','required',['select', 'box'=>'manuf', 'valueField'=>'id', 'descField'=>'breadtitle']],
  178.                 'category_id' => ['int','required',['select', 'box'=>'category', 'valueField'=>'id', 'descField'=>'breadtitle']],
  179.                 'price' =>['int'],
  180.                 'folder' => ['hidden'],
  181.                 'thumb' => [['string', 'maxlen'=>120],'img'],
  182.                 'slug' => [
  183.                         ['slug','field'=>'title'],
  184.                         ['string', 'maxlen'=>120],
  185.                         ['unique']
  186.                     ],
  187.                 'title' => [['string', 'maxlen'=>120],'required',['unique','fields'=>['parent_id']]],
  188.                 'metatitle' => [['string', 'maxlen'=>120],['defaultCopy','field'=>'title']],
  189.                 'breadtitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  190.                 'menutitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  191.                 'article' => [['article', 'maxlen'=>60000]],
  192.                 'preview' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  193.                 'metadesc' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  194.                 'img1' => [['string', 'maxlen'=>120],'img'],
  195.                 'img2' => [['string', 'maxlen'=>120],'img'],
  196.                 'img3' => [['string', 'maxlen'=>120],'img'],
  197.                 'img4' => [['string', 'maxlen'=>120],'img'],
  198.                 'img5' => [['string', 'maxlen'=>120],'img'],
  199.             ],
  200.         ],
  201.         'relations' => [
  202.             'manuf'=> [
  203.                 'boxName'=> 'manuf',
  204.                 'type'=>'one',
  205.                 'modelField' => 'manuf_id',
  206.                 'boxField' => 'id',
  207.             ],
  208.             'category'=> [
  209.                 'boxName'=> 'category',
  210.                 'type'=>'one',
  211.                 'modelField' => 'category_id',
  212.                 'boxField' => 'id',
  213.             ],
  214.             'parent'=> [
  215.                 'boxName'=> 'page',
  216.                 'type'=>'one',
  217.                 'modelField' => 'parent_id',
  218.                 'boxField' => 'id',
  219.             ],
  220.         ],
  221.         'box' => [
  222.             'table' => 'page',
  223.             'where' =>[['type'=>'product','trash'=>0]],
  224.             'limit' => 21,
  225.             'order' => 'sort',
  226.         ],
  227.     ],
  228.     // Категории
  229.     'category' => [
  230.         'class' => 'page',
  231.         'rules' => [
  232.             'search' => [
  233.                 'title' => [['string', 'maxlen'=>120]],
  234.                 'article' => [['string', 'maxlen'=>60000]],
  235.             ],
  236.             'default' => [
  237.                 'id' => ['int'],
  238.                 'sort' => ['int'],
  239.                 'parent_id' => ['int',['defaultSave','value'=>50]], // categoryList
  240.                 'type' => ['string',['defaultSave','value'=>'category']],
  241.                 'created' => ['int','timeCreate'],
  242.                 'updated' => ['int','timeUpdate'],
  243.                 'trash' => ['boolean'],
  244.                 'needmenu' => ['boolean'],                
  245.                 'list1' => ['boolean'],
  246.                 'folder' => ['hidden'],
  247.                 'thumb' => [['string', 'maxlen'=>120],'img'],
  248.                 'slug' => [['slug','field'=>'title'],['string', 'maxlen'=>120],['unique','fields'=>['parent_id']]],
  249.                 'title' => [['string', 'maxlen'=>120],'required',['unique','fields'=>['parent_id']]],
  250.                 'metatitle' => [['string', 'maxlen'=>120],['defaultCopy','field'=>'title']],
  251.                 'breadtitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  252.                 'menutitle' => [['string', 'maxlen'=>60],['defaultCopyStrict','field'=>'title', 'maxlen'=>60]],
  253.                 'article' => [['article', 'maxlen'=>60000]],
  254.                 'preview' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  255.                 'metadesc' => [['text', 'maxlen'=>250],['defaultCopyStrict','field'=>'article', 'maxlen'=>250]],
  256.             ],
  257.         ],
  258.         'relations' => [
  259.             'parent'=> [
  260.                 'boxName'=> 'page',
  261.                 'type'=>'one',
  262.                 'modelField' => 'parent_id',
  263.                 'boxField' => 'id',
  264.             ],
  265.             'products'=> [
  266.                 'boxName'=> 'product',
  267.                 'type'=>'many',
  268.                 'modelField' => 'id',
  269.                 'boxField' => 'category_id',
  270.             ],
  271.         ],
  272.         'box' => [
  273.             'table' => 'page',
  274.             'where' =>[['type'=>'category','trash'=>0]],
  275.             'order' => 'sort',
  276.         ],
  277.     ],
  278. ];
Advertisement
Add Comment
Please, Sign In to add comment