本文整理汇总了PHP中app\models\Activity::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::create方法的具体用法?PHP Activity::create怎么用?PHP Activity::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Activity
的用法示例。
在下文中一共展示了Activity::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attachTo
public function attachTo(Request $request)
{
$this->validate($request, ['classroom_id' => 'required|exists:classrooms,id', 'quiz_id' => 'required|exists:quizzes,id'], ['required' => 'Kolom :attribute diperlukan']);
$quiz = Quiz::findOrFail($request->quiz_id);
Activity::create(['teacher_id' => $request->user()->id, 'classroom_id' => $request->classroom_id, 'action' => 'Membagikan quiz ke ', 'route' => 'classrooms.quizdetail', 'detail' => $quiz->id]);
$quiz->classrooms()->sync([$request->classroom_id], false);
\Flash::success('Quiz berhasil dibagikan.');
return redirect()->back();
}
示例2: updateAssign
public function updateAssign($id, $requestData)
{
$lead = Leads::findOrFail($id);
$input = $requestData->get('fk_user_id_assign');
$input = array_replace($requestData->all());
$lead->fill($input)->save();
$insertedName = $lead->assignee->name;
$activityinput = array_merge(['text' => auth()->user()->name . ' assigned lead to ' . $insertedName, 'user_id' => Auth()->id(), 'type' => 'lead', 'type_id' => $id]);
Activity::create($activityinput);
}
示例3: attachTo
public function attachTo(Request $request)
{
$this->validate($request, ['classroom_id' => 'required|exists:classrooms,id', 'assignment_id' => 'required|exists:assignments,id', 'deadline' => 'required'], ['required' => 'Kolom :attribute diperlukan']);
$assignment = Assignment::findOrFail($request->assignment_id);
Activity::create(['teacher_id' => $request->user()->id, 'classroom_id' => $request->classroom_id, 'action' => 'Membagikan tugas ke ', 'route' => 'classrooms.assignmentdetail', 'detail' => $assignment->id]);
$start = Carbon::parse($request->start);
$deadline = Carbon::parse($request->deadline);
$assignment->classrooms()->sync([$request->classroom_id => ['start' => $start, 'deadline' => $deadline]], false);
\Flash::success('Tugas berhasil dibagikan.');
return redirect()->back();
}
示例4: updateAssign
public function updateAssign($id, $requestData)
{
$task = Tasks::with('assignee')->findOrFail($id);
$input = $requestData->get('fk_user_id_assign');
$input = array_replace($requestData->all());
$task->fill($input)->save();
$task = $task->fresh();
$insertedName = $task->assignee->name;
$activityinput = array_merge(['text' => auth()->user()->name . ' assigned task to ' . $insertedName, 'user_id' => auth()->id(), 'type' => 'task', 'type_id' => $id]);
Activity::create($activityinput);
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$assoc_id = $request->input('assoc_id');
$data = $request->except('_method', '_token', 'assoc_id');
if ($act = Models\Activity::create($data)) {
if ($act->assocs()->attach($assoc_id)) {
return redirect(action('Admin\\ActivityController@index'));
}
} else {
return redirect(action('Admin\\ActivityController@create'))->withInput()->withErrors('添加活动失败');
}
}
示例6: handle
/**
* Handle the event.
*
* @param ClientAction $event
* @return void
*/
public function handle(ClientAction $event)
{
$client = $event->getClient();
switch ($event->getAction()) {
case 'created':
$text = Lang::get('misc.log.client.created', ['company' => $client->company_name, 'assignee' => $client->AssignedUser->name]);
break;
default:
break;
}
$activityinput = array_merge(['text' => $text, 'user_id' => Auth()->id(), 'type' => Client::class, 'type_id' => $client->id, 'action' => $event->getAction()]);
Activity::create($activityinput);
}
示例7: handle
/**
* Handle the event.
*
* @param TaskAction $event
* @return void
*/
public function handle(TaskAction $event)
{
switch ($event->getAction()) {
case 'created':
$text = Lang::get('misc.log.task.created', ['title' => $event->getTask()->title, 'creator' => $event->getTask()->taskCreator->name, 'assignee' => $event->getTask()->assignee->name]);
break;
case 'updated_status':
$text = Lang::get('misc.log.task.status', ['username' => Auth()->user()->name]);
break;
case 'updated_time':
$text = Lang::get('misc.log.task.time', ['username' => Auth()->user()->name]);
break;
case 'updated_assign':
$text = Lang::get('misc.log.task.assign', ['username' => Auth()->user()->name, 'assignee' => $event->getTask()->assignee->name]);
break;
default:
break;
}
$activityinput = array_merge(['text' => $text, 'user_id' => Auth()->id(), 'type' => Tasks::class, 'type_id' => $event->getTask()->id, 'action' => $event->getAction()]);
Activity::create($activityinput);
}
示例8: handle
/**
* Handle the event.
*
* @param LeadAction $event
* @return void
*/
public function handle(LeadAction $event)
{
switch ($event->getAction()) {
case 'created':
$text = Lang::get('misc.log.lead.created', ['title' => $event->getLead()->title, 'creator' => $event->getLead()->createdBy->name, 'assignee' => $event->getLead()->assignee->name]);
break;
case 'updated_status':
$text = Lang::get('misc.log.lead.status', ['username' => Auth()->user()->name]);
break;
case 'updated_deadline':
$text = Lang::get('misc.log.lead.deadline', ['username' => Auth()->user()->name]);
break;
case 'updated_assign':
$text = Lang::get('misc.log.lead.assign', ['username' => Auth()->user()->name, 'assignee' => $event->getLead()->assignee->name]);
break;
default:
break;
}
$activityinput = array_merge(['text' => $text, 'user_id' => Auth()->id(), 'type' => Leads::class, 'type_id' => $event->getLead()->id, 'action' => $event->getAction()]);
Activity::create($activityinput);
}
示例9: addActivity
/**
* Create an Activity.
*
* @param int $uid
* @param string $activityType
* @param int $sourceId
* @param string $sourceType
* @param int $pid
* @return void
* @throws Exception
*/
public function addActivity($uid, $activityType, $sourceId, $sourceType, $pid = NULL)
{
try {
$activity = ['user_id' => $uid, 'activity_type' => $activityType, 'source_id' => $sourceId, 'source_type' => $sourceType, 'profile_id' => $pid];
Activity::create($activity);
} catch (Exception $e) {
throw $e;
}
}