本文整理汇总了PHP中app\Activity::createActivity方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::createActivity方法的具体用法?PHP Activity::createActivity怎么用?PHP Activity::createActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Activity
的用法示例。
在下文中一共展示了Activity::createActivity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
public function authenticate()
{
$username = Input::get('username');
$password = Input::get('password');
$remember = Input::get('remember');
if (Auth::viaRemember() || Auth::attempt(['email' => $username, 'password' => $password], $remember) || Auth::attempt(['username' => $username, 'password' => $password], $remember)) {
// Authentication passed...
$thisactivity = new Activity();
$thisactivity->createActivity(Auth::user(), 'login', 'have logged in', 0);
return redirect()->intended('/home');
} else {
return redirect()->intended('/login')->withErrors(['Username and/or Password you entered does not belong to any user']);
}
}
示例2: getLogout
protected function getLogout()
{
if (Auth::check()) {
$thisactivity = new Activity();
$thisactivity->createActivity(Auth::user(), 'login', 'have logged out', 0);
}
Auth::logout();
Session::flush();
return redirect()->intended('/login');
}
示例3: qa
public function qa($id, $q, Request $request)
{
$user = User::find($request->user()->id);
$exam = Exams::where(['code' => $id])->firstOrFail();
$availableQuestions = $exam->questions()->count();
if ($availableQuestions < $exam->items) {
$exam->items = $availableQuestions;
}
$this->data['exam'] = $exam;
if ($q == 0) {
$thisactivity = new Activity();
$thisactivity->createActivity($user, 'exam', 'took the Exam : ' . $exam->title, 0);
$thisassess = $user->assessment()->create(['exam_id' => $exam->id, 'status' => 0]);
$this->data['status'] = "start";
} else {
$assesment = User::find($user->id)->assessment()->where(['exam_id' => $exam->id])->get()->last();
$questions = $exam->questions()->whereNotExists(function ($query) use($user, $assesment) {
$query->select('answers.question_id')->from('answers')->whereRaw('answers.question_id = questions.id AND answers.exam_id = questions.exam AND answers.user_id = "' . $user->id . '" AND answers.assessment_id = "' . $assesment->id . '"');
})->get();
if (count($questions)) {
$question = $questions->random(1)->toArray();
$this->data['status'] = "exam";
$question['questionid'] = $q;
$ac = 0;
$questionarray = json_decode($question['choices']);
$question['choices'] = array_map(function ($k, $a) {
$b = [];
$b['text'] = $a;
$b['id'] = $k;
return $b;
}, range(0, count($questionarray) - 1), $questionarray);
shuffle($question['choices']);
$this->data['assessment'] = $assesment->toArray();
$this->data['question'] = $question;
} else {
$this->data['status'] = "result";
$correct = Answers::where(['exam_id' => $exam->id, 'assessment_id' => $assesment->id, 'user_id' => $user->id, 'answer' => 0])->count();
$answered = Answers::where(['exam_id' => $exam->id, 'assessment_id' => $assesment->id, 'user_id' => $user->id])->count();
$this->data['score'] = ['total' => $exam->items, 'answered' => $answered, 'correct' => $correct];
$assessment = $assesment;
$assessment->status = 1;
if ($exam->items > 0) {
$assessment->score = $correct / $exam->items;
} else {
$assessment->score = 0;
}
$assessment->save();
}
}
return view('home.questions', $this->data);
}