本文整理汇总了PHP中app\Comment::whereBelongsTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::whereBelongsTo方法的具体用法?PHP Comment::whereBelongsTo怎么用?PHP Comment::whereBelongsTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::whereBelongsTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
public function show(Ticket $ticket)
{
if (!Entrust::can('view_ticket')) {
return redirect('/dashboard')->withErrors(config('constants.NA'));
}
if (!Entrust::hasRole('admin')) {
$ticket = $ticket->with('assignedUser')->whereId($ticket->id)->whereHas('assignedUser', function ($query) {
$query->where('user_id', '=', Auth::user()->id);
})->first();
}
if (!$ticket) {
return redirect('/ticket')->withErrors('You cannot access a ticket without permission.');
}
$departments = Department::lists('department_name', 'id')->all();
$ticket_types = TicketType::lists('ticket_type_name', 'id')->all();
$priorities = config('list.priority');
$ticket_status = config('list.ticket_status');
$comments = \App\Comment::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->get();
$note = \App\Note::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->first();
$attachments = \App\Attachment::whereBelongsTo('ticket')->whereUniqueId($ticket->id)->get();
$ticket_array = $ticket->toArray();
$users = User::with('roles')->whereHas('roles', function ($query) {
$query->where('roles.name', '!=', 'user');
})->lists('name', 'id')->all();
$ticket_with_user = $ticket->whereId($ticket->id)->with('assignedUser')->first();
$selected_users = array();
foreach ($ticket_with_user->assignedUser as $user) {
$selected_users[] = $user->id;
}
$custom_field_values = Helper::getCustomFieldValues($this->form, $ticket->id);
$template_list = array();
$templates = Helper::getTemplate();
foreach ($templates as $key => $template) {
if ($key != 'forgot_password' && $template['category'] == 'ticket') {
$template_list[$key] = $template['title'];
}
}
return view('ticket.show', compact('ticket', 'departments', 'ticket_types', 'priorities', 'users', 'selected_users', 'ticket_with_user', 'ticket_array', 'ticket_status', 'comments', 'note', 'attachments', 'custom_field_values', 'template_list'));
}