本文整理汇总了PHP中app\Message::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::count方法的具体用法?PHP Message::count怎么用?PHP Message::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: composeDashboard
private function composeDashboard()
{
view()->composer('admin.index', function ($view) {
$numArticle = \App\Article::count();
$numCategory = \App\Category::count();
$numTag = \App\Tag::count();
$numProject = \App\Project::count();
$numMessage = \App\Message::count();
$view->with(compact('numArticle', 'numCategory', 'numTag', 'numProject', 'numMessage'));
});
}
示例2: Home
public function Home(Request $request)
{
$page = (int) ($request->get('p', '1') > 0 ? $request->get('p', '1') : 1);
$isPageMax = false;
$messages = Message::orderBy('id', 'desc')->skip(($page - 1) * 10)->take(10)->get();
if (count($messages) == 0 && $page > 1) {
$pagemax = ceil(Message::count() / 10);
return Redirect::route('adminMinichat', array('p' => $pagemax));
}
$nextMessages = Message::orderBy('id', 'desc')->skip($page * 10)->take(1)->get();
if (count($nextMessages) == 0) {
$isPageMax = true;
}
return view('admin.minichat.home', compact('page', 'isPageMax', 'messages'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$messages = null;
if (!$request->has('accepted')) {
$messages = Message::orderBy('created_at', 'desc')->simplePaginate(20);
} else {
if ($request->get('accepted') > 0) {
$messages = Message::where('accepted', 1)->orderBy('created_at', 'desc')->simplePaginate(20);
$messages->appends(['accepted' => 1]);
} else {
if ($request->get('accepted') <= 0) {
$messages = Message::where('accepted', 0)->orderBy('created_at', 'desc')->simplePaginate(20);
$messages->appends(['accepted' => 0]);
} else {
$messages = Message::orderBy('created_at', 'desc')->simplePaginate(20);
}
}
}
$total = Message::count();
$total_approved = Message::where('accepted', 1)->count();
return response()->json(['data' => $messages->toArray(), 'total_count' => $total, 'approved_count' => $total_approved]);
}
示例4: index
public function index()
{
$count = ['articles' => Article::count(), 'registrants' => Registrant::count(), 'users' => User::count(), 'messages' => Message::count()];
return view('admin.dashboard', compact('count'));
}
示例5: stestJoinChat
public function stestJoinChat()
{
$user = User::firstOrFail();
$chat = Chat::create($this->chatroomdata);
$action = Bus::dispatch(new JoinChat($user, $chat));
// add
$this->assertNull($action->admin);
$this->assertTrue($chat->users->contains($user->id));
$this->assertEquals(1, $chat->messages->count());
$this->assertEquals(1, $chat->users->count());
$action = Bus::dispatch(new LeaveChat($user, $chat));
// remove
$this->assertEquals(2, Message::count());
// $this->assertEquals(0, $chat->users->count());
$admin = User::all()->last();
$this->assertNotNull($admin);
$this->assertNotEquals($admin->id, $user->id);
$action = Bus::dispatch(new JoinChat($user, $chat, $admin));
// add
$this->assertEquals($action->admin->id, $admin->id);
$action = Bus::dispatch(new LeaveChat($user, $chat, $admin));
// remove
}
示例6: check_single_corr
public function check_single_corr($event_id)
{
$user = Auth::user();
$data = Input::all();
$level = $data['level'];
$answer = $data['answer'];
// $event_id = $data['event_id'];
$event_name = $event_id;
$event = Event::where('event_name', $event_id)->first();
if ($event == null) {
return ['status' => 0, '_token' => csrf_token()];
}
$start = strtotime($event->start_time);
$end = strtotime($event->end_time);
$now = time() + 5.5 * 60 * 60;
if ($end < $now) {
//Event has finished ...
return ['status' => 0, '_token' => csrf_token()];
} else {
if ($start < $now && $end > $now) {
//Event is ongoing ...
$question_tuple = Question::where('level', $level)->where('event_id', $event->id)->first();
$user_level = Score::where('user_id', $user->id)->where('event_id', $event->id)->first()['level'];
$randomint = rand(1, Message::count());
$message = Message::find($randomint);
$response = [];
if ($user_level == $level - 1) {
$ans = Answers::where('ques_id', $question_tuple->id)->first();
if ($ans['answer'] == $answer) {
$score = Score::where('user_id', $user->id)->where('event_id', $event->id)->first();
$score->score += $ans['score'];
$score->level += 1;
$score->updated_at = date('Y-m-d H:i:s', time());
$score->save();
if ($score->level == $event->num_ques) {
return ['status' => 1, 'end' => 1];
}
//if level == num_ques then display end page...
$fetched = self::fetch_ques($event_name, $score->level + 1);
$next_q = $fetched['question'];
$response['status'] = 1;
$response['message'] = $message->correct;
$response['question'] = $next_q;
if ($next_q->html != "" || $next_q->html != null) {
$response['html'] = $next_q->html;
}
if ($next_q->image != "" || $next_q->image != null) {
$response['image'] = $next_q->image;
}
$response['level'] = $level + 1;
$response['user_level'] = $user_level + 1;
$response['rank'] = $next_q['rank'];
$response['_token'] = csrf_token();
return $response;
} else {
$response['status'] = 0;
$response['message'] = $message->incorrect;
$response['rank'] = self::rank($event_id);
$response['_token'] = csrf_token();
}
}
//for event type == 3 sc w/ bt and input
//do something else..
return $response;
//return more values to spice it up??
} else {
//Event hasn't started yet ...
return ['status' => 0, '_token' => csrf_token(), 're' => 1];
//can make this interesting ??
//perhaps a waiting area.. ? <<<---- To be done...
}
}
}