當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Comment::whereBelongsTo方法代碼示例

本文整理匯總了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'));
 }
開發者ID:EneaWeb,項目名稱:aliangel,代碼行數:39,代碼來源:TicketController.php


注:本文中的app\Comment::whereBelongsTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。