コード例 #1
0
 /**
  * Returns <option> tag with appropriate value and select attribute for the specified limit amount
  *
  * @param string $currentPath
  * @param int $optionTagLimit
  * @return string
  */
 public static function optionTag($currentPath, $optionTagLimit)
 {
     $routeParameters = array_merge(['page' => 1, 'limit' => $optionTagLimit], Request::except('page', 'limit'));
     $htmlTag = '<option value="' . RoutePresenter::withParam($currentPath, $routeParameters) . '" ';
     $currentLimit = (int) Request::input('limit', 10);
     if ($optionTagLimit === $currentLimit) {
         $htmlTag .= 'selected ';
     }
     return $htmlTag . '>' . $optionTagLimit . '</option>';
 }
コード例 #2
0
 /**
  * @param \Illuminate\Http\Request $request
  * @param string $currentPath
  * @return boolean
  */
 private function beforeMiddleware($request, $currentPath)
 {
     $storedSearchQuery = LookInStorage::forSearch($request, $currentPath);
     $storedPageNumber = LookInStorage::forPage($request, $currentPath);
     $storedPerPage = LookInStorage::forLimit($request, $currentPath);
     $shouldRedirect = (bool) $storedSearchQuery || (bool) $storedPageNumber || (bool) $storedPerPage;
     if ($shouldRedirect) {
         $redirectParameters = LookInStorage::forRedirectParameters($request->all(), $storedSearchQuery, $storedPageNumber, $storedPerPage);
         $this->redirectRoute = RoutePresenter::withParam($currentPath, $redirectParameters);
     }
     return $shouldRedirect;
 }
コード例 #3
0
 /**
  * Returns current uri with params for sorting by the specified property
  *
  * @param string $currentPath
  * @param string $currentSortFieldName
  * @param boolean $currentSortIsAscending
  * @param string $columnName
  * @return string
  */
 public static function anchorTagLink($currentPath, $currentSortFieldName, $currentSortIsAscending, $columnName)
 {
     $linkSortsAscending = $currentSortFieldName === $columnName ? !$currentSortIsAscending : false;
     $routeParameters = array_merge(['sortedBy' => $columnName, 'asc' => $linkSortsAscending], Request::except('sortedBy', 'asc'));
     return RoutePresenter::withParam($currentPath, $routeParameters);
 }