idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
227,000 | public function getOwner ( ) { $ uuid = $ this -> getProperty ( 'owner' ) ; $ url = $ this -> makeAbsoluteUrl ( '/api/users' , $ this -> getLink ( 'project' ) ) ; return Account :: get ( $ uuid , $ url , $ this -> client ) ; } | Get the account for the project s owner . |
227,001 | public function getProject ( ) { if ( ! $ this -> hasLink ( 'project' ) && ! $ this -> isActive ( ) ) { throw new \ BadMethodCallException ( 'Inactive subscriptions do not have projects.' ) ; } $ url = $ this -> getLink ( 'project' ) ; return Project :: get ( $ url , null , $ this -> client ) ; } | Get the project associated with this subscription . |
227,002 | public function wait ( callable $ onPoll = null , callable $ onLog = null , $ pollInterval = 1 ) { $ log = $ this -> getProperty ( 'log' ) ; if ( $ onLog !== null && strlen ( trim ( $ log ) ) ) { $ onLog ( trim ( $ log ) . "\n" ) ; } $ length = strlen ( $ log ) ; $ retries = 0 ; while ( ! $ this -> isComplete ( ) ) { u... | Wait for the activity to complete . |
227,003 | public function restore ( $ target = null , $ branchFrom = null ) { if ( $ this -> getProperty ( 'type' ) !== 'environment.backup' ) { throw new \ BadMethodCallException ( 'Cannot restore activity (wrong type)' ) ; } if ( ! $ this -> isComplete ( ) ) { throw new \ BadMethodCallException ( 'Cannot restore backup (not co... | Restore the backup associated with this activity . |
227,004 | public function getDescription ( $ html = false ) { $ description = $ this -> getProperty ( 'description' ) ; if ( $ html ) { return $ description ; } return html_entity_decode ( strip_tags ( $ description ) , ENT_QUOTES , 'utf-8' ) ; } | Get a human - readable description of the activity . |
227,005 | public static function inflections ( $ block = false ) { if ( $ block ) { return call_user_func ( $ block , Inflections :: instance ( ) ) ; } else { return Inflections :: instance ( ) ; } } | Yields a singleton instance of Inflections so you can specify additional inflector rules . |
227,006 | private static function stringToSeconds ( $ duration ) { if ( isset ( self :: $ suffixes [ substr ( $ duration , - 1 ) ] ) ) { $ amount = substr ( $ duration , 0 , strlen ( $ duration ) - 1 ) ; $ unit = self :: $ suffixes [ substr ( $ duration , - 1 ) ] ; } else { $ unit = 1 ; $ amount = $ duration ; } if ( ! is_numeri... | Converts a duration string to seconds . |
227,007 | public function getAccount ( ) { $ uuid = $ this -> getProperty ( 'id' ) ; $ url = $ this -> makeAbsoluteUrl ( '/api/users' ) ; $ account = Account :: get ( $ uuid , $ url , $ this -> client ) ; if ( ! $ account ) { throw new \ Exception ( "Account not found for user: " . $ uuid ) ; } return $ account ; } | Get the account information for this user . |
227,008 | public function getEnvironmentRole ( Environment $ environment ) { $ access = $ environment -> getUser ( $ this -> id ) ; return $ access ? $ access -> role : false ; } | Get the user s role on an environment . |
227,009 | public function changeEnvironmentRole ( Environment $ environment , $ newRole ) { $ access = $ environment -> getUser ( $ this -> id ) ; if ( $ access ) { if ( $ access -> role === $ newRole ) { throw new \ InvalidArgumentException ( "There is nothing to change" ) ; } return $ access -> update ( [ 'role' => $ newRole ]... | Change the user s environment - level role . |
227,010 | public function signData ( $ data , PrivateKey $ privateKey , $ algorithm = OPENSSL_ALGO_SHA256 , $ format = self :: FORMAT_DER ) { Assert :: oneOf ( $ format , [ self :: FORMAT_ECDSA , self :: FORMAT_DER ] , 'The format %s to sign request does not exists. Available format: %s' ) ; $ resource = $ privateKey -> getResou... | Generate a signature of the given data using a private key and an algorithm . |
227,011 | private function DERtoECDSA ( $ der , $ partLength ) { $ hex = unpack ( 'H*' , $ der ) [ 1 ] ; if ( '30' !== mb_substr ( $ hex , 0 , 2 , '8bit' ) ) { throw new DataSigningException ( 'Invalid signature provided' ) ; } if ( '81' === mb_substr ( $ hex , 2 , 2 , '8bit' ) ) { $ hex = mb_substr ( $ hex , 6 , null , '8bit' )... | Convert a DER signature into ECDSA . |
227,012 | public function signCertificateRequest ( CertificateRequest $ certificateRequest ) { $ csrObject = $ this -> createCsrWithSANsObject ( $ certificateRequest ) ; if ( ! $ csrObject || ! openssl_csr_export ( $ csrObject , $ csrExport ) ) { throw new CSRSigningException ( sprintf ( 'OpenSSL CSR signing failed with error: %... | Generate a CSR from the given distinguishedName and keyPair . |
227,013 | protected function createCsrWithSANsObject ( CertificateRequest $ certificateRequest ) { $ sslConfigTemplate = <<<'EOL'[ req ]distinguished_name = req_distinguished_namereq_extensions = v3_req[ req_distinguished_name ][ v3_req ]basicConstraints = CA:FALSEkeyUsage = nonRepudiation, digitalSignature, keyEnciphermentsubj... | Generate a CSR object with SANs from the given distinguishedName and keyPair . |
227,014 | private function getCSRPayload ( DistinguishedName $ distinguishedName ) { $ payload = [ ] ; if ( null !== $ countryName = $ distinguishedName -> getCountryName ( ) ) { $ payload [ 'countryName' ] = $ countryName ; } if ( null !== $ stateOrProvinceName = $ distinguishedName -> getStateOrProvinceName ( ) ) { $ payload [... | Retrieves a CSR payload from the given distinguished name . |
227,015 | public function generateKeyPair ( $ keyOption = null ) { if ( null === $ keyOption ) { $ keyOption = new RsaKeyOption ( ) ; } if ( \ is_int ( $ keyOption ) ) { @ trigger_error ( 'Passing a keySize to "generateKeyPair" is deprecated since version 1.1 and will be removed in 2.0. Pass an instance of KeyOption instead' , E... | Generate KeyPair . |
227,016 | public function parse ( Key $ key ) { try { $ resource = $ key -> getResource ( ) ; } catch ( KeyFormatException $ e ) { throw new KeyParsingException ( 'Fail to load resource for key' , 0 , $ e ) ; } $ rawData = openssl_pkey_get_details ( $ resource ) ; openssl_free_key ( $ resource ) ; if ( ! \ is_array ( $ rawData )... | Parse the key . |
227,017 | public function parse ( Certificate $ certificate ) { $ rawData = openssl_x509_parse ( $ certificate -> getPEM ( ) ) ; if ( ! \ is_array ( $ rawData ) ) { throw new CertificateParsingException ( sprintf ( 'Fail to parse certificate with error: %s' , openssl_error_string ( ) ) ) ; } if ( ! isset ( $ rawData [ 'subject' ... | Parse the certificate . |
227,018 | public function onWsdlResponse ( WsdlResponseEvent $ event ) { $ xpath = new \ DOMXPath ( $ event -> getWsdl ( ) ) ; $ xpath -> registerNamespace ( 'wsaw' , self :: NS_WSAW ) ; if ( $ xpath -> query ( '//wsaw:Addressing' ) -> length || $ xpath -> query ( '//wsaw:UsingAddressing' ) -> length ) { $ this -> wsaEnabled = t... | Parse the WSDL to check if WS - Addressing should be enabled |
227,019 | public function onRequest ( RequestEvent $ event ) { if ( ! $ this -> wsaEnabled ) { return ; } $ request = $ event -> getRequest ( ) ; $ envelope = $ request -> documentElement ; $ soapNS = $ envelope -> namespaceURI ; $ xpath = new \ DOMXPath ( $ event -> getRequest ( ) ) ; $ xpath -> registerNamespace ( 'soap' , $ s... | Add WS - Addressing headers to the request |
227,020 | public function enableTotp ( Request $ request , Google2FA $ totpProvider ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; if ( ! $ secret = array_get ( $ twoFactor , 'totp.secret' ) ) { $ twoFactor [ 'totp' ] = [ 'enabled' => false , 'secret' => $ sec... | Enable TwoFactor TOTP authentication . |
227,021 | public function updateTotp ( AccountTwoFactorTotpProcessRequest $ request , Google2FA $ totpProvider ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ secret = array_get ( $ twoFactor , 'totp.secret' ) ; $ backup = array_get ( $ twoFactor , 'totp.back... | Process the TwoFactor TOTP enable form . |
227,022 | public function backupTotp ( AccountTwoFactorTotpBackupRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'totp' ] [ 'backup' ] = $ this -> generateTotpBackups ( ) ; $ twoFactor [ 'totp' ] [ 'backup_at' ] = now ( ) -> toDa... | Process the TwoFactor OTP backup . |
227,023 | public function enablePhone ( AccountTwoFactorPhoneRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> routeNotificationForAuthy ( ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'phone' ] [ 'enabled' ] = true ; $ currentUser -> fill ( [ 'two_factor'... | Enable TwoFactor Phone authentication . |
227,024 | public function disablePhone ( Request $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ twoFactor = $ currentUser -> getTwoFactor ( ) ; $ twoFactor [ 'phone' ] [ 'enabled' ] = false ; $ currentUser -> fill ( [ 'two_factor' => $ twoFactor ] ) -> forceSave ( ) ; return intend ( [ 'back' => t... | Disable TwoFactor Phone authentication . |
227,025 | protected function generateTotpBackups ( ) : array { $ backup = [ ] ; for ( $ x = 0 ; $ x <= 9 ; $ x ++ ) { $ backup [ ] = str_pad ( ( string ) random_int ( 0 , 9999999999 ) , 10 , '0' , STR_PAD_BOTH ) ; } return $ backup ; } | Generate TwoFactor OTP backup codes . |
227,026 | public function encodeDecimal ( $ integer , $ options ) { if ( $ integer === 1 << ( \ PHP_INT_SIZE * 8 - 1 ) ) { return sprintf ( '(int)%s%d' , $ options [ 'whitespace' ] ? ' ' : '' , $ integer ) ; } return var_export ( $ integer , true ) ; } | Encodes an integer into decimal representation . |
227,027 | public function encodeHexadecimal ( $ integer , $ options ) { if ( $ options [ 'hex.capitalize' ] ) { return sprintf ( '%s0x%X' , $ this -> sign ( $ integer ) , abs ( $ integer ) ) ; } return sprintf ( '%s0x%x' , $ this -> sign ( $ integer ) , abs ( $ integer ) ) ; } | Encodes an integer into hexadecimal representation . |
227,028 | public function getCulture ( $ culture = null ) : ? array { return $ this -> getCultures ( ) [ $ culture ] ?? ( ! empty ( $ this -> getCultures ( ) ) ? current ( $ this -> getCultures ( ) ) : null ) ; } | Get the given culture . |
227,029 | public function divider ( int $ order = null , array $ attributes = [ ] ) : MenuItem { return $ this -> add ( [ 'type' => 'divider' , 'order' => $ order , 'attributes' => $ attributes ] ) ; } | Add new divider item . |
227,030 | public function publish ( $ message ) { $ serializedMessage = $ this -> serializer -> wrapAndSerialize ( $ message ) ; $ routingKey = $ this -> routingKeyResolver -> resolveRoutingKeyFor ( $ message ) ; $ additionalProperties = $ this -> additionalPropertiesResolver -> resolveAdditionalPropertiesFor ( $ message ) ; $ t... | Publish the given Message by serializing it and handing it over to a RabbitMQ producer |
227,031 | public function handleProviderCallback ( Request $ request , string $ provider ) { $ providerUser = Socialite :: driver ( $ provider ) -> user ( ) ; $ fullName = explode ( ' ' , $ providerUser -> name ) ; $ attributes = [ 'id' => $ providerUser -> id , 'email' => $ providerUser -> email , 'username' => $ providerUser -... | Obtain the user information from Provider . |
227,032 | protected function getLocalUser ( string $ provider , string $ providerUserId ) { return app ( 'cortex.auth.admin' ) -> whereHas ( 'socialites' , function ( Builder $ builder ) use ( $ provider , $ providerUserId ) { $ builder -> where ( 'provider' , $ provider ) -> where ( 'provider_uid' , $ providerUserId ) ; } ) -> ... | Get local user for the given provider . |
227,033 | public static function isSupported ( ) { if ( version_compare ( PHP_VERSION , '7.2' , '>=' ) && \ defined ( 'PASSWORD_ARGON2I' ) ) { return true ; } if ( class_exists ( '\\ParagonIE_Sodium_Compat' ) && method_exists ( '\\ParagonIE_Sodium_Compat' , 'crypto_pwhash_is_available' ) ) { return \ ParagonIE_Sodium_Compat :: c... | Check that the password handler is supported in this environment |
227,034 | public function login ( AuthenticationRequest $ request ) { $ loginField = get_login_field ( $ request -> input ( $ this -> username ( ) ) ) ; $ credentials = [ 'is_active' => true , $ loginField => $ request -> input ( 'loginfield' ) , 'password' => $ request -> input ( 'password' ) , ] ; if ( $ this -> hasTooManyLogi... | Process to the login form . |
227,035 | protected function processLogout ( Request $ request ) : void { auth ( ) -> guard ( $ this -> getGuard ( ) ) -> logout ( ) ; $ request -> session ( ) -> invalidate ( ) ; } | Process logout . |
227,036 | protected function overrideMiddleware ( Router $ router ) : void { $ router -> pushMiddlewareToGroup ( 'web' , UpdateLastActivity :: class ) ; $ router -> aliasMiddleware ( 'reauthenticate' , Reauthenticate :: class ) ; $ router -> aliasMiddleware ( 'guest' , RedirectIfAuthenticated :: class ) ; } | Override middleware . |
227,037 | public function ifCan ( string $ ability , $ params = null , $ guard = null ) { $ this -> hideCallbacks -> push ( function ( ) use ( $ ability , $ params , $ guard ) { return ! optional ( auth ( ) -> guard ( $ guard ) -> user ( ) ) -> can ( $ ability , $ params ) ; } ) ; return $ this ; } | Set authorization callback for current menu item . |
227,038 | public function activateOnRoute ( string $ route ) { $ this -> activeWhen = function ( ) use ( $ route ) { return str_contains ( Route :: currentRouteName ( ) , $ route ) ; } ; return $ this ; } | Set active callback on the given route . |
227,039 | protected function add ( array $ properties = [ ] ) { $ properties [ 'attributes' ] [ 'id' ] = $ properties [ 'attributes' ] [ 'id' ] ?? md5 ( json_encode ( $ properties ) ) ; $ this -> childs -> push ( $ item = new static ( $ properties ) ) ; return $ item ; } | Add new child item . |
227,040 | protected function hasActiveStateFromChilds ( ) : bool { return $ this -> getChilds ( ) -> contains ( function ( MenuItem $ child ) { return ( $ child -> hasChilds ( ) && $ child -> hasActiveStateFromChilds ( ) ) || ( $ child -> route && $ child -> hasActiveStateFromRoute ( ) ) || $ child -> isActive ( ) || $ child -> ... | Check if the item has active state from childs . |
227,041 | private function isClassName ( $ value , array $ options ) { if ( preg_match ( '/^([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(\\\\(?1))*$/' , $ value ) !== 1 ) { return false ; } return array_intersect ( iterator_to_array ( $ this -> iterateNamespaces ( $ value ) ) , $ options [ 'string.classes' ] ) !== [ ] ; } | Tests if the given value is a string that could be encoded as a class name constant . |
227,042 | private function getClassName ( $ value , array $ options ) { foreach ( $ this -> iterateNamespaces ( $ value ) as $ partial ) { if ( isset ( $ options [ 'string.imports' ] [ $ partial ] ) ) { $ trimmed = substr ( $ value , \ strlen ( rtrim ( $ partial , '\\' ) ) ) ; return ltrim ( sprintf ( '%s%s::class' , rtrim ( $ o... | Encodes the given string as a class name constant based on used imports . |
227,043 | private function iterateNamespaces ( $ value ) { yield $ value ; $ parts = explode ( '\\' , '\\' . $ value ) ; $ count = \ count ( $ parts ) ; for ( $ i = 1 ; $ i < $ count ; $ i ++ ) { yield ltrim ( implode ( '\\' , \ array_slice ( $ parts , 0 , - $ i ) ) , '\\' ) . '\\' ; } } | Iterates over the variations of the namespace for the given class name . |
227,044 | private function getComplexString ( $ value , array $ options ) { if ( $ this -> isBinaryString ( $ value , $ options ) ) { return $ this -> encodeBinaryString ( $ value ) ; } if ( $ options [ 'string.escape' ] ) { return $ this -> getDoubleQuotedString ( $ value , $ options ) ; } return $ this -> getSingleQuotedString... | Returns the PHP code representation for the string that is not just simple ascii characters . |
227,045 | private function getDoubleQuotedString ( $ string , $ options ) { $ string = strtr ( $ string , [ "\n" => '\n' , "\r" => '\r' , "\t" => '\t' , '$' => '\$' , '"' => '\"' , '\\' => '\\\\' , ] ) ; if ( $ options [ 'string.utf8' ] ) { $ string = $ this -> encodeUtf8 ( $ string , $ options ) ; } $ hexFormat = function ( $ m... | Returns the string wrapped in double quotes and all but print characters escaped . |
227,046 | private function encodeUtf8 ( $ string , $ options ) { $ pattern = '/ [\xC2-\xDF][\x80-\xBF] | \xE0[\xA0-\xBF][\x80-\xBF] | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} | \xED[\x80-\x9F][\x80-\xBF] | \xF0[\x90-\xBF][\x80-\xBF]{2} | [\xF1-\xF3][\x80-\xBF]{3} ... | Encodes all multibyte UTF - 8 characters into PHP7 string encoding . |
227,047 | private function getCodePoint ( $ bytes ) { if ( \ strlen ( $ bytes ) === 2 ) { return ( ( \ ord ( $ bytes [ 0 ] ) & 0b11111 ) << 6 ) | ( \ ord ( $ bytes [ 1 ] ) & 0b111111 ) ; } if ( \ strlen ( $ bytes ) === 3 ) { return ( ( \ ord ( $ bytes [ 0 ] ) & 0b1111 ) << 12 ) | ( ( \ ord ( $ bytes [ 1 ] ) & 0b111111 ) << 6 ) |... | Returns the unicode code point for the given multibyte UTF - 8 character . |
227,048 | public function setTenantsAttribute ( $ tenants ) : void { static :: saved ( function ( self $ model ) use ( $ tenants ) { $ tenants = collect ( $ tenants ) -> filter ( ) ; $ model -> tenants -> pluck ( 'id' ) -> similar ( $ tenants ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attributes' => [ 't... | Attach the given tenants to the model . |
227,049 | public function messageConsumptionFailed ( MessageConsumptionFailed $ event ) { $ this -> logger -> log ( $ this -> logLevel , $ this -> logMessage , [ 'exception' => $ event -> exception ( ) , 'message' => $ event -> message ( ) ] ) ; } | Log the failed message and the related exception |
227,050 | public function scopeGuestsBySeconds ( Builder $ builder , $ seconds = 60 ) : Builder { return $ builder -> where ( 'last_activity' , '>=' , time ( ) - $ seconds ) -> whereNull ( 'user_id' ) ; } | Constrain the query to retrieve only sessions of guests who have been active within the specified number of seconds . |
227,051 | public function scopeUsersBySeconds ( Builder $ builder , $ seconds = 60 ) : Builder { return $ builder -> with ( [ 'user' ] ) -> where ( 'last_activity' , '>=' , now ( ) -> subSeconds ( $ seconds ) ) -> whereNotNull ( 'user_id' ) ; } | Constrain the query to retrieve only sessions of users who have been active within the specified number of seconds . |
227,052 | public function destroy ( Admin $ admin , Media $ media ) { $ admin -> media ( ) -> where ( $ media -> getKeyName ( ) , $ media -> getKey ( ) ) -> first ( ) -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.admins.edit' , [ 'admin' => $ admin ] ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messag... | Destroy given admin media . |
227,053 | public function import ( Guardian $ guardian , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ guardian , 'tabs' => 'adminarea.guardians.tabs' , 'url' => route ( 'adminarea.guardians.stash' ) , 'id' => "adminarea-attributes-{$guardian->getRouteKey()}-impor... | Import guardians . |
227,054 | public function destroy ( Guardian $ guardian ) { $ guardian -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.guardians.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.guardian' ) , 'identifier' => $ guardian -> usern... | Destroy given guardian . |
227,055 | protected function attemptTwoFactor ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { return $ this -> isValidTwoFactorTotp ( $ user , $ token ) || $ this -> isValidTwoFactorBackup ( $ user , $ token ) || $ this -> isValidTwoFactorPhone ( $ user , $ token ) ; } | Verify TwoFactor authentication . |
227,056 | protected function invalidateTwoFactorBackup ( AuthenticatableTwoFactorContract $ user , int $ token ) : void { $ settings = $ user -> getTwoFactor ( ) ; $ backup = array_get ( $ settings , 'totp.backup' ) ; unset ( $ backup [ array_search ( $ token , $ backup ) ] ) ; array_set ( $ settings , 'totp.backup' , $ backup )... | Invalidate given backup code for the given user . |
227,057 | protected function isValidTwoFactorPhone ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ settings = $ user -> getTwoFactor ( ) ; $ authyId = array_get ( $ settings , 'phone.authy_id' ) ; return in_array ( mb_strlen ( $ token ) , [ 6 , 7 , 8 ] ) && app ( 'rinvex.authy.token' ) -> verify ( $ token , ... | Determine if the given token is a valid TwoFactor Phone token . |
227,058 | protected function isValidTwoFactorBackup ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ backup = array_get ( $ user -> getTwoFactor ( ) , 'totp.backup' , [ ] ) ; $ result = mb_strlen ( $ token ) === 10 && in_array ( $ token , $ backup ) ; ! $ result || $ this -> invalidateTwoFactorBackup ( $ user... | Determine if the given token is a valid TwoFactor Backup code . |
227,059 | protected function isValidTwoFactorTotp ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ totpProvider = app ( Google2FA :: class ) ; $ secret = array_get ( $ user -> getTwoFactor ( ) , 'totp.secret' ) ; return mb_strlen ( $ token ) === 6 && $ totpProvider -> verifyKey ( $ secret , $ token ) ; } | Determine if the given token is a valid TwoFactor TOTP token . |
227,060 | protected function createAdmin ( string $ password ) : Admin { $ admin = [ 'is_active' => true , 'username' => 'Admin' , 'given_name' => 'Admin' , 'family_name' => 'User' , 'email' => 'admin@example.com' , ] ; return tap ( app ( 'cortex.auth.admin' ) -> firstOrNew ( $ admin ) -> fill ( [ 'remember_token' => str_random ... | Create admin model . |
227,061 | protected function createGuardian ( string $ password ) : Guardian { $ guardian = [ 'is_active' => true , 'username' => 'Guardian' , 'email' => 'guardian@example.com' , ] ; return tap ( app ( 'cortex.auth.guardian' ) -> firstOrNew ( $ guardian ) -> fill ( [ 'remember_token' => str_random ( 10 ) , 'password' => $ passwo... | Create guardian model . |
227,062 | public function setAbilitiesAttribute ( $ abilities ) : void { static :: saved ( function ( self $ model ) use ( $ abilities ) { $ abilities = collect ( $ abilities ) -> filter ( ) ; $ model -> abilities -> pluck ( 'id' ) -> similar ( $ abilities ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attri... | Attach the given abilities to the model . |
227,063 | public function setRolesAttribute ( $ roles ) : void { static :: saved ( function ( self $ model ) use ( $ roles ) { $ roles = collect ( $ roles ) -> filter ( ) ; $ model -> roles -> pluck ( 'id' ) -> similar ( $ roles ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attributes' => [ 'roles' => $ rol... | Attach the given roles to the model . |
227,064 | public function routeNotificationForAuthy ( ) : ? int { if ( ! ( $ authyId = array_get ( $ this -> getTwoFactor ( ) , 'phone.authy_id' ) ) && $ this -> getEmailForVerification ( ) && $ this -> getPhoneForVerification ( ) && $ this -> getCountryForVerification ( ) ) { $ result = app ( 'rinvex.authy.user' ) -> register (... | Route notifications for the authy channel . |
227,065 | public function getManagedRoles ( ) : Collection { if ( $ this -> isA ( 'superadmin' ) ) { $ roles = app ( 'cortex.auth.role' ) -> all ( ) ; } elseif ( $ this -> isA ( 'supermanager' ) ) { $ roles = $ this -> roles -> merge ( config ( 'rinvex.tenants.active' ) ? app ( 'cortex.auth.role' ) -> where ( 'scope' , config ( ... | Get managed roles . |
227,066 | public function getManagedAbilities ( ) : Collection { $ abilities = $ this -> isA ( 'superadmin' ) ? app ( 'cortex.auth.ability' ) -> all ( ) : $ this -> getAbilities ( ) ; return $ abilities -> groupBy ( 'entity_type' ) -> map -> pluck ( 'title' , 'id' ) -> sortKeys ( ) ; } | Get managed abilites . |
227,067 | public function import ( Admin $ admin , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ admin , 'tabs' => 'adminarea.admins.tabs' , 'url' => route ( 'adminarea.admins.stash' ) , 'id' => "adminarea-attributes-{$admin->getRouteKey()}-import-table" , ] ) -> ... | Import admins . |
227,068 | public function destroy ( Admin $ admin ) { $ admin -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.admins.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.admin' ) , 'identifier' => $ admin -> username ] ) ] , ] ) ; ... | Destroy given admin . |
227,069 | public static function language ( $ code , $ hydrate = true ) { $ code = mb_strtolower ( $ code ) ; if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } if ( ! isset ( static :: $ languages [ $ code ] ) ) { throw Lan... | Get the language by it s ISO ISO 639 - 1 code . |
227,070 | public static function scripts ( ) { if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } return static :: pluck ( static :: $ languages , 'script.name' , 'script.iso_15924' ) ; } | Get all language scripts . |
227,071 | public static function families ( ) { if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } return static :: pluck ( static :: $ languages , 'family.name' , 'family.iso_639_5' ) ; } | Get all language families . |
227,072 | public function lockout ( Lockout $ event ) : void { if ( config ( 'cortex.auth.emails.throttle_lockout' ) ) { switch ( $ event -> request -> route ( 'accessarea' ) ) { case 'managerarea' : $ model = app ( 'cortex.auth.manager' ) ; break ; case 'adminarea' : $ model = app ( 'cortex.auth.admin' ) ; break ; case 'frontar... | Listen to the authentication lockout event . |
227,073 | public function destroy ( Session $ session ) { $ session -> delete ( ) ; return intend ( [ 'back' => true , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.session' ) , 'identifier' => $ session -> getKey ( ) ] ) ] , ] ) ; } | Destroy given session . |
227,074 | public function flush ( Request $ request ) { $ request -> user ( $ this -> getGuard ( ) ) -> sessions ( ) -> delete ( ) ; return intend ( [ 'back' => true , 'with' => [ 'warning' => trans ( 'cortex/auth::messages.auth.session.flushed' ) ] , ] ) ; } | Flush all sessions . |
227,075 | public function edit ( Request $ request ) { $ countries = collect ( countries ( ) ) -> map ( function ( $ country , $ code ) { return [ 'id' => $ code , 'text' => $ country [ 'name' ] , 'emoji' => $ country [ 'emoji' ] , ] ; } ) -> values ( ) ; $ languages = collect ( languages ( ) ) -> pluck ( 'name' , 'iso_639_1' ) ... | Edit account settings . |
227,076 | public function update ( AccountSettingsRequest $ request ) { $ data = $ request -> validated ( ) ; $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; ! $ request -> hasFile ( 'profile_picture' ) || $ currentUser -> addMediaFromRequest ( 'profile_picture' ) -> sanitizingFileName ( function ( $ fileName ) { ... | Update account settings . |
227,077 | public function update ( AccountAttributesRequest $ request ) { $ data = $ request -> validated ( ) ; $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> fill ( $ data ) -> save ( ) ; return intend ( [ 'back' => true , 'with' => [ 'success' => trans ( 'cortex/auth::messages.account.updated_a... | Update account attributes . |
227,078 | private function getAlignedArray ( array $ array , $ depth , array $ options , callable $ encode ) { $ next = 0 ; $ omit = $ options [ 'array.omit' ] ; foreach ( array_keys ( $ array ) as $ key ) { if ( $ key !== $ next ++ ) { $ omit = false ; break ; } } return $ omit ? $ this -> getFormattedArray ( $ array , $ depth ... | Returns the PHP code for aligned array accounting for omitted keys and inline arrays . |
227,079 | private function getFormattedArray ( array $ array , $ depth , array $ options , callable $ encode ) { $ lines = $ this -> getPairs ( $ array , ' ' , $ options [ 'array.omit' ] , $ encode , $ omitted ) ; if ( $ omitted && $ options [ 'array.inline' ] !== false ) { $ output = $ this -> getInlineArray ( $ lines , $ optio... | Returns the PHP code for the array as inline or multi line array . |
227,080 | private function getInlineArray ( array $ lines , array $ options ) { $ output = $ this -> wrap ( implode ( ', ' , $ lines ) , $ options [ 'array.short' ] ) ; if ( preg_match ( '/[\r\n\t]/' , $ output ) ) { return false ; } elseif ( $ options [ 'array.inline' ] === true || \ strlen ( $ output ) <= ( int ) $ options [ '... | Returns the code for the inline array if possible . |
227,081 | private function buildArray ( array $ lines , $ depth , array $ options ) { $ indent = $ this -> buildIndent ( $ options [ 'array.base' ] , $ options [ 'array.indent' ] , $ depth + 1 ) ; $ last = $ this -> buildIndent ( $ options [ 'array.base' ] , $ options [ 'array.indent' ] , $ depth ) ; $ eol = $ options [ 'array.e... | Builds the complete array from the encoded key and value pairs . |
227,082 | private function buildIndent ( $ base , $ indent , $ depth ) { $ base = \ is_int ( $ base ) ? str_repeat ( ' ' , $ base ) : ( string ) $ base ; return $ depth === 0 ? $ base : $ base . str_repeat ( \ is_int ( $ indent ) ? str_repeat ( ' ' , $ indent ) : ( string ) $ indent , $ depth ) ; } | Builds the indentation based on the options . |
227,083 | private function getAlignedPairs ( array $ array , callable $ encode ) { $ keys = [ ] ; $ values = [ ] ; foreach ( $ array as $ key => $ value ) { $ keys [ ] = $ encode ( $ key , 1 ) ; $ values [ ] = $ encode ( $ value , 1 ) ; } $ format = sprintf ( '%%-%ds => %%s' , max ( array_map ( 'strlen' , $ keys ) ) ) ; $ pairs ... | Returns each encoded key and value pair with aligned assignment operators . |
227,084 | private function getPairs ( array $ array , $ space , $ omit , callable $ encode , & $ omitted = true ) { $ pairs = [ ] ; $ nextIndex = 0 ; $ omitted = true ; $ format = '%s' . $ space . '=>' . $ space . '%s' ; foreach ( $ array as $ key => $ value ) { if ( $ omit && $ this -> canOmitKey ( $ key , $ nextIndex ) ) { $ p... | Returns each key and value pair encoded as array assignment . |
227,085 | private function canOmitKey ( $ key , & $ nextIndex ) { $ result = $ key === $ nextIndex ; if ( \ is_int ( $ key ) ) { $ nextIndex = max ( $ key + 1 , $ nextIndex ) ; } return $ result ; } | Tells if the key can be omitted from array output based on expected index . |
227,086 | public function import ( Ability $ ability , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ ability , 'tabs' => 'adminarea.abilities.tabs' , 'url' => route ( 'adminarea.abilities.stash' ) , 'id' => "adminarea-abilities-{$ability->getRouteKey()}-import-tab... | Import abilities . |
227,087 | public function destroy ( Ability $ ability ) { $ ability -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.abilities.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.ability' ) , 'identifier' => $ ability -> title ] ) ... | Destroy given ability . |
227,088 | public function addEncoder ( Encoder \ Encoder $ encoder , $ prepend = false ) { $ prepend ? array_unshift ( $ this -> encoders , $ encoder ) : array_push ( $ this -> encoders , $ encoder ) ; } | Adds a new encoder . |
227,089 | public function setOption ( $ option , $ value ) { if ( ! $ this -> isValidOption ( $ option ) ) { throw new InvalidOptionException ( sprintf ( "Invalid encoder option '%s'" , $ option ) ) ; } $ this -> options [ $ option ] = $ value ; } | Sets the value for an encoder option . |
227,090 | private function isValidOption ( $ option ) { if ( array_key_exists ( $ option , $ this -> options ) ) { return true ; } foreach ( $ this -> encoders as $ encoder ) { if ( array_key_exists ( $ option , $ encoder -> getDefaultOptions ( ) ) ) { return true ; } } return false ; } | Tells if the given string is a valid option name . |
227,091 | public function getAllOptions ( array $ overrides = [ ] ) { $ options = $ this -> options ; foreach ( $ this -> encoders as $ encoder ) { $ options += $ encoder -> getDefaultOptions ( ) ; } foreach ( $ overrides as $ name => $ value ) { if ( ! array_key_exists ( $ name , $ options ) ) { throw new InvalidOptionException... | Returns a list of all encoder options . |
227,092 | private function generate ( $ value , $ depth , array $ options , array $ recursion = [ ] ) { if ( $ this -> detectRecursion ( $ value , $ options , $ recursion ) ) { $ recursion [ ] = $ value ; } if ( $ options [ 'recursion.max' ] !== false && $ depth > ( int ) $ options [ 'recursion.max' ] ) { throw new \ RuntimeExce... | Generates the code for the given value recursively . |
227,093 | private function detectRecursion ( & $ value , array $ options , array $ recursion ) { if ( $ options [ 'recursion.detect' ] ) { if ( array_search ( $ value , $ recursion , true ) !== false ) { if ( $ options [ 'recursion.ignore' ] ) { $ value = null ; } else { throw new \ RuntimeException ( 'A recursive value was dete... | Attempts to detect circular references in values . |
227,094 | private function encodeValue ( $ value , $ depth , array $ options , callable $ encode ) { foreach ( $ this -> encoders as $ encoder ) { if ( $ encoder -> supports ( $ value ) ) { return $ encoder -> encode ( $ value , $ depth , $ options , $ encode ) ; } } throw new \ InvalidArgumentException ( sprintf ( "Unsupported ... | Encodes the value using one of the encoders that supports the value type . |
227,095 | private function encodeObject ( $ object , array $ options , callable $ encode ) { if ( $ options [ 'object.format' ] === 'string' ) { return $ encode ( ( string ) $ object ) ; } elseif ( $ options [ 'object.format' ] === 'serialize' ) { return sprintf ( 'unserialize(%s)' , $ encode ( serialize ( $ object ) ) ) ; } els... | Encodes the object as string according to encoding options . |
227,096 | private function encodeObjectArray ( $ object , array $ options , callable $ encode ) { if ( ! \ in_array ( ( string ) $ options [ 'object.format' ] , [ 'array' , 'vars' , 'iterate' ] , true ) ) { throw new \ RuntimeException ( 'Invalid object encoding format: ' . $ options [ 'object.format' ] ) ; } $ output = $ encode... | Encodes the object into one of the array formats . |
227,097 | private function getObjectArray ( $ object , $ format ) { if ( $ format === 'array' ) { return ( array ) $ object ; } elseif ( $ format === 'vars' ) { return get_object_vars ( $ object ) ; } $ array = [ ] ; foreach ( $ object as $ key => $ value ) { $ array [ $ key ] = $ value ; } return $ array ; } | Converts the object into array that can be encoded . |
227,098 | private function getObjectState ( $ object ) { $ class = new \ ReflectionClass ( $ object ) ; $ visibility = \ ReflectionProperty :: IS_PRIVATE | \ ReflectionProperty :: IS_PROTECTED ; $ values = [ ] ; do { foreach ( $ class -> getProperties ( $ visibility ) as $ property ) { $ property -> setAccessible ( true ) ; $ va... | Returns an array of object properties as would be generated by var_export . |
227,099 | private function encodeNumber ( $ float , array $ options , callable $ encode ) { if ( $ this -> isInteger ( $ float , $ options [ 'float.integers' ] ) ) { return $ this -> encodeInteger ( $ float , $ encode ) ; } elseif ( $ float === 0.0 ) { return '0.0' ; } elseif ( $ options [ 'float.export' ] ) { return var_export ... | Encodes the number as a PHP number representation . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.