本文整理匯總了PHP中Participant::filterParticipantNames方法的典型用法代碼示例。如果您正苦於以下問題:PHP Participant::filterParticipantNames方法的具體用法?PHP Participant::filterParticipantNames怎麽用?PHP Participant::filterParticipantNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Participant
的用法示例。
在下文中一共展示了Participant::filterParticipantNames方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* 更新請求
*
* @param Request $request
* @param int $id
* @return void
*/
public function update(Request $request, $id)
{
// 驗證
$this->validate($request, ['topic' => 'string', 'participants' => 'string', 'state' => 'required|in:1,-1', 'reply_message' => 'required|string']);
$log = Comment::find($id);
// 更新
DB::transaction(function () use($request, $log) {
if (Comment::STATUS['ENABLE'] == $request->state) {
// 參與人
$participantIds = [];
$participantNames = Participant::filterParticipantNames($request->participants);
if (!empty($participantNames)) {
foreach ($participantNames as $name) {
$participant = Participant::firstOrCreate(['name' => $name]);
$participant->increment('counts', 1);
$participantIds[] = $participant->id;
}
}
// 節目
$program = Program::where('date', date('Y-m-d', strtotime($log->metas->thread_key)))->first();
$topic = Program::filterTopic($request->topic);
if (!empty($topic)) {
$program->update(['topic' => $topic]);
}
if (!empty($participantIds)) {
$program->participants()->sync($participantIds);
}
}
// 刷新首頁文件緩存
Cache::forget(Program::INDEX_CACHE_KEY);
// 刷新貢獻記錄頁文件緩存
Cache::forget(Comment::CONTRIBUTION_CACHE_KEY);
// 記錄日誌
Comment::where('id', $log->id)->update(['ext_is_agree' => $request->state]);
});
// 回複評論
$state = Comment::replyPost($request->reply_message, $log->metas->thread_id, $log->metas->post_id, $log->metas->author_email);
// 跳轉
$status = ['status' => $state ? 'success' : 'error', 'message' => $state ? '審核成功~' : '審核成功,回複失敗'];
return Redirect::to($request->_redirect_url)->with($status['status'], $status['message']);
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// 獲取文本路徑
$path = $this->argument('path');
if (!is_file($path)) {
return $this->error("Invalid file path {$path}.");
}
// 解析數據
$list = self::decodeText($path);
// 插入數據
foreach ($list as $group) {
DB::transaction(function () use(&$group) {
// 插入聲音記錄
self::insertAudios($group);
// 插入參與人記錄
$data = $group['all'] ?? end($group);
$participantIds = [];
$participantNames = Participant::filterParticipantNames($data['participant']);
foreach ($participantNames as $name) {
$participant = Participant::firstOrCreate(['name' => $name]);
$participant->increment('counts', 1);
$participantIds[] = $participant->id;
}
// 插入節目記錄
$topic = Program::filterTopic($data['topic']);
if (empty($group['all'])) {
if (in_array(mb_substr($topic, -1), ['a', 'b', 'c'])) {
$topic = mb_substr($topic, 0, -1);
}
}
$program = Program::firstOrCreate(['date' => $data['date'], 'topic' => $topic, 'state' => Program::STATE_ENABLE]);
if (!empty($participantIds)) {
$program->participants()->sync($participantIds);
}
// 輸出日期
$this->info(sprintf("%s\t%s", $data['date'], $topic));
});
}
}