getCurrentRequest() public static method

Get the request currently being dispatched.
public static getCurrentRequest ( ) : Illuminate\Http\Request
return Illuminate\Http\Request
Example #1
0
 public function check($parSegments, $parLastSegment = null)
 {
     $allSegments = \Route::getCurrentRequest()->segments();
     $countSegments = count($allSegments) - 1;
     if ($countSegments < 0) {
         $countSegments = 0;
     }
     if (empty($allSegments)) {
         $firstSegment = '';
         $lastSegment = '';
     } else {
         $firstSegment = $allSegments[0];
         $lastSegment = $allSegments[$countSegments];
     }
     if (is_string($parSegments)) {
         return $firstSegment == $parSegments && (!$parLastSegment || $parLastSegment == $lastSegment) ? 'active' : '';
     } elseif (is_array($parSegments)) {
         $allSegmentsMatch = true;
         for ($i = 0; $i < count($parSegments); $i++) {
             if (!array_key_exists($i, $parSegments) || !array_key_exists($i, $allSegments) || $parSegments[$i] != $allSegments[$i]) {
                 $allSegmentsMatch = false;
                 break;
             }
         }
         return $allSegmentsMatch && (!$parLastSegment || $parLastSegment == $lastSegment) ? 'active' : '';
     } else {
         return '';
     }
 }
Example #2
0
 /**
  * @param Guard          $auth
  * @param PasswordBroker $password
  */
 public function __construct(Guard $auth, PasswordBroker $password)
 {
     $this->request = \Route::getCurrentRequest();
     $this->auth = $auth;
     $this->passwords = $password;
 }