app/Http/Controllers/TicketController.php
/**
     * Display a listing of the resource.
     *
     * @param Request $request
     * @return Response
     */
Display a listing of the resource.
@param Request $request
@return Response
Display a listing of the resource . @param Request $request @return Response
public function index(Request $request)
    {
        $user = auth()->user();
        $categories = TicketCategory::all();
        $statuses = Ticket::STATUSES;
        $ticketQuery = $user->tickets()->orderByDesc('created_at');
        if ($request->input('title')) {
            $ticketQuery->where('title', 'LIKE', '%' . $request->input('title') . '%');
        }
        $ticketQuery->whereBetween('created_at', [
            $request->input('creation_date_min') ?? Carbon::minValue()->toDateTimeString(),
            $request->input('creation_date_max') ?? Carbon::maxValue()->toDateTimeString()
        ]);
        if ($request->input('categories')) {
            $ticketQuery->whereIn('category_id', $request->input('categories'));
        }
        if ($request->input('statuses')) {
            $ticketQuery->whereIn('status', $request->input('statuses'));
        }
        $tickets = $ticketQuery->paginate(5);
        return view('ticket.index', [
            'categories' => $categories,
            'statuses' => $statuses,
            'tickets' => $tickets,
        ]);
    }
public function index ( Request $ request ) { $ user = auth ( ) -> user ( ) ; $ categories = TicketCategory :: all ( ) ; $ statuses = Ticket :: STATUSES ; $ ticketQuery = $ user -> tickets ( ) -> orderByDesc ( 'created_at' ) ; if ( $ request -> input ( 'title' ) ) { $ ticketQuery -> where ( 'title' , 'LIKE' , '%' . $ request -> input ( 'title' ) . '%' ) ; } $ ticketQuery -> whereBetween ( 'created_at' , [ $ request -> input ( 'creation_date_min' ) ?? Carbon :: minValue ( ) -> toDateTimeString ( ) , $ request -> input ( 'creation_date_max' ) ?? Carbon :: maxValue ( ) -> toDateTimeString ( ) ] ) ; if ( $ request -> input ( 'categories' ) ) { $ ticketQuery -> whereIn ( 'category_id' , $ request -> input ( 'categories' ) ) ; } if ( $ request -> input ( 'statuses' ) ) { $ ticketQuery -> whereIn ( 'status' , $ request -> input ( 'statuses' ) ) ; } $ tickets = $ ticketQuery -> paginate ( 5 ) ; return view ( 'ticket.index' , [ 'categories' => $ categories , 'statuses' => $ statuses , 'tickets' => $ tickets , ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
/** @var User $user */