コード例 #1
0
ファイル: functions.php プロジェクト: schpill/standalone
 function getDrafts($type, $user)
 {
     $collection = [];
     if (is_object($user)) {
         $user = $user->id;
     }
     if (!is_numeric($user)) {
         throw new Exception('People must be an instance of people or be an id');
     }
     $auth = ['in', 'out'];
     if (!arrays::in($type, $auth)) {
         throw new Exception('An offer must be "in" or "out".');
     }
     $drafts = bigDb('draft' . $type)->where(['people_id', '=', $user])->exec(true);
     foreach ($drafts as $draft) {
         $status = opt($draft)->get('status', 1);
         if (1 == $status) {
             array_push($collection, $draft->assoc());
         }
     }
     return $collection;
 }