示例#1
0
文件: Data.php 项目: newset/wx
 public function getIndex(Request $req)
 {
     $user = $req->user();
     $marked = DB::table('user_marked')->where('user_id', $user->id)->count();
     $total = $unmarked = 0;
     if (!Session::get('total_wx_count')) {
         Session::set('total_wx_count', Weixin::count());
         Session::set('unmarked_wx_count', Weixin::whereNull('marking')->orWhere('marking', 0)->count());
     }
     $total = Session::get('total_wx_count');
     $unmarked = Session::get('unmarked_wx_count');
     return ['me' => $marked, 'total' => $total, 'unmarked' => $unmarked, 'marked' => $total - $unmarked, 'pending' => Weixin::where('marking', 0)->count()];
 }
示例#2
0
文件: WeixinCtrl.php 项目: newset/wx
 private function next($last)
 {
     $next = null;
     if ($last) {
         $row = Weixin::with(['articles', 'tags'])->where('marking', 0)->find($last);
         if ($row) {
             return $row;
         }
     }
     DB::transaction(function () use(&$next) {
         $next = Weixin::with(['articles', 'tags'])->whereNull('marking')->orderBy('priority', 'desc')->first();
         $next->marking = 0;
         $next->save();
     });
     return $next;
 }