Esempio n. 1
0
 public function search($input)
 {
     $query = Partners::query();
     $columns = Schema::getColumnListing('partners');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Esempio n. 2
0
 public static function partner($parameter = "")
 {
     $from = \Carbon\Carbon::now()->modify('-3 month');
     $to = \Carbon\Carbon::now();
     if ($parameter == "") {
         return Md\Partners::where('status', 'active')->count();
     }
     if ($parameter == "trial") {
         return Md\Partners::where(function ($query) use($from, $to) {
             $query->where('status', 'active')->whereBetween('created_at', array($from, $to));
         })->count();
     }
     if ($parameter == "active") {
         return Md\Partners::where(function ($query) use($from, $to) {
             $query->where('status', 'active')->whereBetween('created_at', array($from, $to))->Where('created_at', '<=', $from);
         })->count();
     }
 }