Sufyan

SnapNCook Sample

Feb 25th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. //Controller    
  2. $languages = $this->Query->getAllDataList('Languages',
  3.       [
  4.         'Languages.is_published' => 1,
  5.         'Languages.is_active' => 1
  6.       ],
  7.       ['Languages.name']
  8.     );
  9. //Template
  10.                 <div class="form-group">
  11.                   <label for="mother_tounge_language_id">Mother Tounge</label> <!-- Mother Tounge -->
  12.                   <?= $this->Form->select('mother_tounge_language_id',
  13.                       $languages,
  14.                       [
  15.                         'id' => 'mother_tounge_language_id',
  16.                         'empty' => '(Choose mother tounge)',
  17.                         'class' => 'form-control select2',
  18.                         'required' => 'required'
  19.                       ]
  20.                   )?>
  21.                 </div>
  22.  
  23. //QueryComponent
  24. /**
  25.      *  Get List for Tables
  26.      *
  27.      * @param $model string null
  28.      * @param $conditions array Pass conditions (Where clause)
  29.      * @param $order      array Order By
  30.      *
  31.      * @return array
  32.      */
  33.     public function getAllDataList($model = null, $conditions = [], $order = [], $contain = []) {
  34.         if ($model != null) {
  35.             $items = TableRegistry::get($model);
  36.         }
  37.  
  38.         $query = $items->find('list')
  39.                 ->where($conditions)
  40.                 ->contain($contain)
  41.                 ->order($order);
  42.                
  43.         return $query;
  44.     }
Add Comment
Please, Sign In to add comment