idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
42,500 | public function setAccountExpiry ( $ expiryTime ) { $ time = is_null ( $ expiryTime ) ? '9223372036854775807' : ( string ) Utilities :: convertUnixTimeToWindowsTime ( $ expiryTime ) ; return $ this -> setFirstAttribute ( $ this -> schema -> accountExpires ( ) , $ time ) ; } | Sets the users account expiry date . |
42,501 | public function getThumbnailEncoded ( ) { if ( $ data = base64_decode ( $ this -> getThumbnail ( ) , $ strict = true ) ) { $ mime = 'image/jpeg' ; $ image = base64_encode ( $ data ) ; if ( function_exists ( 'finfo_open' ) ) { $ finfo = finfo_open ( ) ; $ mime = finfo_buffer ( $ finfo , $ data , FILEINFO_MIME_TYPE ) ; r... | Returns the users thumbnail photo base 64 encoded . |
42,502 | public function setThumbnail ( $ data , $ encode = true ) { if ( $ encode && ! base64_decode ( $ data , $ strict = true ) ) { $ data = base64_encode ( $ data ) ; } return $ this -> setAttribute ( $ this -> schema -> thumbnail ( ) , $ data ) ; } | Sets the users thumbnail photo . |
42,503 | public function setJpegPhoto ( $ string ) { if ( ! base64_decode ( $ string , $ strict = true ) ) { $ string = base64_encode ( $ string ) ; } return $ this -> setAttribute ( $ this -> schema -> jpegPhoto ( ) , $ string ) ; } | Sets the users JPEG photo . |
42,504 | public function getPrimaryGroup ( ) { $ groupSid = preg_replace ( '/\d+$/' , $ this -> getPrimaryGroupId ( ) , $ this -> getConvertedSid ( ) ) ; return $ this -> query -> newInstance ( ) -> findBySid ( $ groupSid ) ; } | Retrieves the primary group of the current user . |
42,505 | public function setPassword ( $ password ) { $ this -> validateSecureConnection ( ) ; $ encodedPassword = Utilities :: encodePassword ( $ password ) ; if ( $ this -> exists ) { return $ this -> addModification ( $ this -> newBatchModification ( $ this -> schema -> unicodePassword ( ) , LDAP_MODIFY_BATCH_REPLACE , [ $ e... | Sets the password on the current user . |
42,506 | public function expirationDate ( ) { $ accountExpiry = $ this -> getAccountExpiry ( ) ; if ( $ accountExpiry == 0 || $ accountExpiry == $ this -> getSchema ( ) -> neverExpiresDate ( ) ) { return ; } $ unixTime = Utilities :: convertWindowsTimeToUnixTime ( $ accountExpiry ) ; return ( new DateTime ( ) ) -> setTimestamp ... | Return the expiration date of the user account . |
42,507 | public function getCurrentTime ( ) { $ time = $ this -> getFirstAttribute ( $ this -> schema -> currentTime ( ) ) ; return DateTime :: createFromFormat ( $ this -> timestampFormat , $ time ) -> getTimestamp ( ) ; } | Returns the hosts current time in unix timestamp format . |
42,508 | public function process ( $ results ) { $ entries = $ this -> connection -> getEntries ( $ results ) ? : [ ] ; if ( $ this -> builder -> isRaw ( ) ) { return $ entries ; } $ models = [ ] ; if ( Arr :: has ( $ entries , 'count' ) ) { for ( $ i = 0 ; $ i < $ entries [ 'count' ] ; $ i ++ ) { $ models [ ] = $ this -> newLd... | Processes LDAP search results and constructs their model instances . |
42,509 | public function newLdapEntry ( array $ attributes = [ ] ) { $ objectClass = $ this -> schema -> objectClass ( ) ; if ( array_key_exists ( $ objectClass , $ attributes ) && array_key_exists ( 0 , $ attributes [ $ objectClass ] ) ) { $ classes = array_map ( 'strtolower' , $ attributes [ $ objectClass ] ) ; $ models = $ t... | Returns a new LDAP Entry instance . |
42,510 | public function newModel ( $ attributes = [ ] , $ model = null ) { $ model = ( class_exists ( $ model ) ? $ model : $ this -> schema -> entryModel ( ) ) ; if ( ! is_subclass_of ( $ model , $ base = Model :: class ) ) { throw new InvalidArgumentException ( "The given model class '{$model}' must extend the base model cla... | Creates a new model instance . |
42,511 | public function newPaginator ( array $ models = [ ] , $ perPage = 25 , $ currentPage = 0 , $ pages = 1 ) { return new Paginator ( $ models , $ perPage , $ currentPage , $ pages ) ; } | Returns a new Paginator object instance . |
42,512 | protected function processSort ( array $ models = [ ] ) { $ field = $ this -> builder -> getSortByField ( ) ; $ flags = $ this -> builder -> getSortByFlags ( ) ; $ direction = $ this -> builder -> getSortByDirection ( ) ; $ desc = ( $ direction === 'desc' ? true : false ) ; return $ this -> newCollection ( $ models ) -... | Sorts LDAP search results . |
42,513 | public function entry ( array $ attributes = [ ] ) { $ model = $ this -> schema -> entryModel ( ) ; return ( new $ model ( $ attributes , $ this -> query ) ) ; } | Creates a new generic LDAP entry instance . |
42,514 | public function user ( array $ attributes = [ ] ) { $ model = $ this -> schema -> userModel ( ) ; return ( new $ model ( $ attributes , $ this -> query ) ) -> setAttribute ( $ this -> schema -> objectClass ( ) , $ this -> schema -> userObjectClasses ( ) ) ; } | Creates a new user instance . |
42,515 | public function group ( array $ attributes = [ ] ) { $ model = $ this -> schema -> groupModel ( ) ; return ( new $ model ( $ attributes , $ this -> query ) ) -> setAttribute ( $ this -> schema -> objectClass ( ) , [ $ this -> schema -> top ( ) , $ this -> schema -> objectCategoryGroup ( ) , ] ) ; } | Creates a new group instance . |
42,516 | public function contact ( array $ attributes = [ ] ) { $ model = $ this -> schema -> contactModel ( ) ; return ( new $ model ( $ attributes , $ this -> query ) ) -> setAttribute ( $ this -> schema -> objectClass ( ) , [ $ this -> schema -> top ( ) , $ this -> schema -> person ( ) , $ this -> schema -> organizationalPer... | Creates a new user instance as a contact . |
42,517 | public function computer ( array $ attributes = [ ] ) { $ model = $ this -> schema -> computerModel ( ) ; return ( new $ model ( $ attributes , $ this -> query ) ) -> setAttribute ( $ this -> schema -> objectClass ( ) , [ $ this -> schema -> top ( ) , $ this -> schema -> person ( ) , $ this -> schema -> organizationalP... | Creates a new computer instance . |
42,518 | private function registerChat ( ) { $ this -> app -> bind ( 'chat' , function ( ) { return $ this -> app -> make ( \ Musonza \ Chat \ Chat :: class ) ; } ) ; } | Registers Chat . |
42,519 | public function publishMigrations ( ) { $ timestamp = date ( 'Y_m_d_His' , time ( ) ) ; $ stub = __DIR__ . '/../database/migrations/create_chat_tables.php' ; $ target = $ this -> app -> databasePath ( ) . '/migrations/' . $ timestamp . '_create_chat_tables.php' ; $ this -> publishes ( [ $ stub => $ target ] , 'chat.mig... | Publish package s migrations . |
42,520 | public function getMessages ( $ user , $ paginationParams , $ deleted = false ) { return $ this -> getConversationMessages ( $ user , $ paginationParams , $ deleted ) ; } | Get messages for a conversation . |
42,521 | public function getList ( $ user , $ perPage = 25 , $ page = 1 , $ pageName = 'page' ) { return $ this -> getConversationsList ( $ user , $ perPage , $ page , $ pageName ) ; } | Gets the list of conversations . |
42,522 | public function addParticipants ( $ userIds ) { if ( is_array ( $ userIds ) ) { foreach ( $ userIds as $ id ) { $ this -> users ( ) -> attach ( $ id ) ; } } else { $ this -> users ( ) -> attach ( $ userIds ) ; } if ( Chat :: makeThreeOrMoreUsersPublic ( ) && $ this -> fresh ( ) -> users -> count ( ) > 2 ) { $ this -> p... | Add user to conversation . |
42,523 | public function removeUsers ( $ users ) { if ( is_array ( $ users ) ) { foreach ( $ users as $ id ) { $ this -> users ( ) -> detach ( $ id ) ; } return $ this ; } $ this -> users ( ) -> detach ( $ users ) ; return $ this ; } | Remove user from conversation . |
42,524 | public function start ( $ participants , $ data = [ ] ) { $ conversation = $ this -> create ( [ 'data' => $ data ] ) ; if ( $ participants ) { $ conversation -> addParticipants ( $ participants ) ; } return $ conversation ; } | Starts a new conversation . |
42,525 | public function userConversations ( $ user ) { $ userId = is_object ( $ user ) ? $ user -> getKey ( ) : $ user ; return $ this -> join ( 'mc_conversation_user' , 'mc_conversation_user.conversation_id' , '=' , 'mc_conversations.id' ) -> where ( 'mc_conversation_user.user_id' , $ userId ) -> where ( 'private' , true ) ->... | Gets conversations for a specific user . |
42,526 | public function unReadNotifications ( $ user ) { $ notifications = MessageNotification :: where ( [ [ 'user_id' , '=' , $ user -> getKey ( ) ] , [ 'conversation_id' , '=' , $ this -> id ] , [ 'is_seen' , '=' , 0 ] ] ) -> get ( ) ; return $ notifications ; } | Get unread notifications . |
42,527 | public function common ( $ users ) { if ( $ users instanceof \ Illuminate \ Database \ Eloquent \ Collection ) { $ users = $ users -> map ( function ( $ user ) { return $ user -> getKey ( ) ; } ) ; } return $ this -> withCount ( [ 'users' => function ( $ query ) use ( $ users ) { $ query -> whereIn ( Chat :: userModelP... | Gets conversations that are common for a list of users . |
42,528 | public function handle ( $ command ) { $ message = $ this -> message -> send ( $ command -> conversation , $ command -> body , $ command -> senderId , $ command -> type ) ; $ this -> dispatcher -> dispatch ( $ this -> message -> releaseEvents ( ) ) ; return $ message ; } | Triggers sending the message . |
42,529 | public function send ( Conversation $ conversation , $ body , $ userId , $ type = 'text' ) { $ message = $ conversation -> messages ( ) -> create ( [ 'body' => $ body , 'user_id' => $ userId , 'type' => $ type , ] ) ; $ messageWasSent = Chat :: sentMessageEvent ( ) ; $ message -> load ( 'sender' ) ; $ this -> raise ( n... | Adds a message to a conversation . |
42,530 | public function getNotification ( $ user ) { return MessageNotification :: where ( 'user_id' , $ user -> getKey ( ) ) -> where ( 'message_id' , $ this -> id ) -> select ( [ 'mc_message_notification.*' , 'mc_message_notification.updated_at as read_at' ] ) -> first ( ) ; } | Return user notification for specific message . |
42,531 | public function getMessages ( ) { return $ this -> conversation -> getMessages ( $ this -> user , $ this -> getPaginationParams ( ) , $ this -> deleted ) ; } | Get messages in a conversation . |
42,532 | public function between ( $ userOne , $ userTwo ) { $ conversation1 = $ this -> conversation -> userConversations ( $ userOne ) -> toArray ( ) ; $ conversation2 = $ this -> conversation -> userConversations ( $ userTwo ) -> toArray ( ) ; $ common_conversations = $ this -> getConversationsInCommon ( $ conversation1 , $ ... | Get Private Conversation between two users . |
42,533 | public function get ( ) { if ( is_null ( $ this -> isPrivate ) ) { return $ this -> conversation -> getList ( $ this -> user , $ this -> perPage , $ this -> page , $ pageName = 'page' ) ; } return $ this -> conversation -> getUserConversations ( $ this -> user , [ 'perPage' => $ this -> perPage , 'page' => $ this -> pa... | Get Conversations with lastest message . |
42,534 | public function from ( $ from ) { $ this -> from = is_object ( $ from ) ? $ from -> getKey ( ) : $ from ; return $ this ; } | Set Sender . |
42,535 | public function page ( int $ page ) { $ this -> page = $ page ? $ page : $ this -> page ; return $ this ; } | Set current page for pagination . |
42,536 | protected function registerFormHelper ( ) { $ this -> app -> singleton ( 'laravel-form-helper' , function ( $ app ) { $ configuration = $ app [ 'config' ] -> get ( 'laravel-form-builder' ) ; return new FormHelper ( $ app [ 'view' ] , $ app [ 'translator' ] , $ configuration ) ; } ) ; $ this -> app -> alias ( 'laravel-f... | Register the form helper . |
42,537 | private function registerFormIfHeeded ( ) { if ( ! $ this -> app -> offsetExists ( 'form' ) ) { $ this -> app -> singleton ( 'form' , function ( $ app ) { $ version = substr ( Application :: VERSION , 0 , 3 ) ; if ( Str :: is ( '5.4' , $ version ) ) { $ form = new LaravelForm ( $ app [ 'html' ] , $ app [ 'url' ] , $ ap... | Add Laravel Form to container if not already set . |
42,538 | private function registerHtmlIfNeeded ( ) { if ( ! $ this -> app -> offsetExists ( 'html' ) ) { $ this -> app -> singleton ( 'html' , function ( $ app ) { return new HtmlBuilder ( $ app [ 'url' ] , $ app [ 'view' ] ) ; } ) ; if ( ! $ this -> aliasExists ( 'Html' ) ) { AliasLoader :: getInstance ( ) -> alias ( 'Html' , ... | Add Laravel Html to container if not already set . |
42,539 | public function setAllowedTags ( $ allowedTags ) { if ( ! is_array ( $ allowedTags ) ) { $ allowedTags = array ( $ allowedTags ) ; } foreach ( $ allowedTags as $ index => $ element ) { if ( is_int ( $ index ) && is_string ( $ element ) ) { $ tagName = strtolower ( $ element ) ; $ this -> allowedTags [ $ tagName ] = [ ]... | Sets the allowedTags property . |
42,540 | public function setAllowedAttributes ( $ allowedAttribs ) { if ( ! is_array ( $ allowedAttribs ) ) { $ allowedAttribs = [ $ allowedAttribs ] ; } foreach ( $ allowedAttribs as $ attribute ) { if ( is_string ( $ attribute ) ) { $ attributeName = strtolower ( $ attribute ) ; $ this -> allowedAttributes [ $ attributeName ]... | Sets the allowedAttributes property . |
42,541 | public function filterCertainTag ( $ tag ) { $ isMatch = preg_match ( '~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~' , $ tag , $ matches ) ; if ( ! $ isMatch ) { return '' ; } $ tagStart = $ matches [ 1 ] ; $ tagName = strtolower ( $ matches [ 2 ] ) ; $ tagAttributes = $ matches [ 3 ] ; $ tagEnd = $ matches [ 5 ] ; if ( ! isset ... | Filters a single tag against the current property data . |
42,542 | protected function getAutoload ( ) { $ composerPath = base_path ( '/composer.json' ) ; if ( ! file_exists ( $ composerPath ) ) { return [ ] ; } $ composer = json_decode ( file_get_contents ( $ composerPath ) , true ) ; return Arr :: get ( $ composer , 'autoload.psr-4' , [ ] ) ; } | Get psr - 4 namespace . |
42,543 | protected function setupValue ( ) { $ value = $ this -> getOption ( $ this -> valueProperty ) ; $ isChild = $ this -> getOption ( 'is_child' ) ; if ( $ value instanceof \ Closure ) { $ this -> valueClosure = $ value ; } if ( ( $ value === null || $ value instanceof \ Closure ) && ! $ isChild ) { $ this -> setValue ( $ ... | Setup the value of the form field . |
42,544 | protected function getModelValueAttribute ( $ model , $ name ) { $ transformedName = $ this -> transformKey ( $ name ) ; if ( is_string ( $ model ) ) { return $ model ; } elseif ( is_object ( $ model ) ) { return object_get ( $ model , $ transformedName ) ; } elseif ( is_array ( $ model ) ) { return Arr :: get ( $ mode... | Get the attribute value from the model by name . |
42,545 | protected function prepareOptions ( array $ options = [ ] ) { $ helper = $ this -> formHelper ; $ rulesParser = $ helper -> createRulesParser ( $ this ) ; $ rules = $ this -> getOption ( 'rules' ) ; $ parsedRules = $ rules ? $ rulesParser -> parse ( $ rules ) : [ ] ; $ this -> options = $ helper -> mergeOptions ( $ thi... | Prepare options for rendering . |
42,546 | public function setOption ( $ name , $ value ) { Arr :: set ( $ this -> options , $ name , $ value ) ; return $ this ; } | Set single option on the field . |
42,547 | public function setType ( $ type ) { if ( $ this -> formHelper -> getFieldType ( $ type ) ) { $ this -> type = $ type ; } return $ this ; } | Set type of the field . |
42,548 | private function allDefaults ( ) { return [ 'wrapper' => [ 'class' => $ this -> getConfig ( 'defaults.wrapper_class' ) ] , 'attr' => [ 'class' => $ this -> getConfig ( 'defaults.field_class' ) ] , 'help_block' => [ 'text' => null , 'tag' => 'p' , 'attr' => [ 'class' => $ this -> getConfig ( 'defaults.help_block_class' ... | Defaults used across all fields . |
42,549 | protected function addErrorClass ( ) { $ errors = $ this -> parent -> getRequest ( ) -> session ( ) -> get ( 'errors' ) ; $ errorBag = $ this -> parent -> getErrorBag ( ) ; if ( $ errors && $ errors -> hasBag ( $ errorBag ) && $ errors -> getBag ( $ errorBag ) -> has ( $ this -> getNameKey ( ) ) ) { $ fieldErrorClass =... | Add error class to wrapper if validation errors exist . |
42,550 | protected function setDefaultOptions ( array $ options = [ ] ) { $ this -> options = $ this -> formHelper -> mergeOptions ( $ this -> allDefaults ( ) , $ this -> getDefaults ( ) ) ; $ this -> options = $ this -> prepareOptions ( $ options ) ; $ defaults = $ this -> setDefaultClasses ( $ options ) ; $ this -> options = ... | Merge all defaults with field specific defaults and set template if passed . |
42,551 | protected function setupLabel ( ) { if ( $ this -> getOption ( 'label' ) !== null ) { return ; } if ( $ template = $ this -> parent -> getTranslationTemplate ( ) ) { $ label = str_replace ( [ '{name}' , '{type}' ] , [ $ this -> getRealName ( ) , 'label' ] , $ template ) ; } elseif ( $ langName = $ this -> parent -> get... | Setup the label for the form field . |
42,552 | protected function needsLabel ( ) { $ isChildSelect = $ this -> type == 'select' && $ this -> getOption ( 'is_child' ) === true ; if ( $ this -> type == 'hidden' || $ isChildSelect ) { return false ; } return true ; } | Check if fields needs label . |
42,553 | public function getValidationRules ( ) { $ rules = $ this -> getOption ( 'rules' , [ ] ) ; $ name = $ this -> getNameKey ( ) ; $ messages = $ this -> getOption ( 'error_messages' , [ ] ) ; $ formName = $ this -> formHelper -> transformToDotSyntax ( $ this -> parent -> getName ( ) ) ; if ( $ messages && $ formName ) { $... | Get validation rules for a field if any with label for attributes . |
42,554 | protected function initFilters ( ) { $ overrideStatus = $ this -> getOption ( 'filters_override' , false ) ; if ( $ overrideStatus ) { $ this -> setFiltersOverride ( true ) ; } $ filters = $ this -> getOption ( 'filters' , [ ] ) ; foreach ( $ filters as $ filter ) { $ this -> addFilter ( $ filter ) ; } return $ this ; ... | Method initFilters used to initialize filters from field options and bind it to the same . |
42,555 | public function setFilters ( array $ filters ) { $ this -> clearFilters ( ) ; foreach ( $ filters as $ filter ) { $ this -> addFilter ( $ filter ) ; } return $ this ; } | Method setFilters used to set filters to current filters property . |
42,556 | protected function digits ( $ param ) { $ digits = $ param [ 0 ] ; if ( $ this -> isNumeric ( ) ) { return [ 'min' => pow ( 10 , $ digits - 1 ) , 'max' => pow ( 10 , $ digits ) - 1 , ] ; } return [ 'pattern' => '\d{' . $ digits . '}' , 'title' => $ this -> getTitle ( 'digits' , compact ( 'digits' ) ) , ] ; } | Check that the value is numeric and contains exactly the given digits . |
42,557 | protected function getTitle ( $ rule , $ params = array ( ) ) { $ params [ 'attribute' ] = $ this -> field -> getOption ( 'label' ) ; return $ this -> formHelper -> getTranslator ( ) -> trans ( 'validation.' . $ rule , $ params ) ; } | Get the title used for validating a rule . |
42,558 | protected function getRulesAsArray ( $ rules ) { $ rulesArray = ( is_string ( $ rules ) ) ? explode ( '|' , $ rules ) : $ rules ; return array_map ( function ( $ rule ) { if ( $ rule instanceof \ Closure ) { return $ rule ( $ this -> field -> getNameKey ( ) ) ; } return $ rule ; } , $ rulesArray ) ; } | Parse field rules as array and initialize closure rules |
42,559 | public static function instance ( $ filter ) { if ( ! is_string ( $ filter ) ) { return self :: validateFilterInstance ( $ filter ) ; } if ( class_exists ( $ filter ) ) { return self :: validateFilterInstance ( new $ filter ( ) ) ; } if ( $ filter = FilterResolver :: resolveFromCollection ( $ filter ) ) { return self :... | Method instance used to resolve filter parameter to FilterInterface object from filter Alias or object itself . |
42,560 | protected function determineChoiceField ( ) { $ expanded = $ this -> options [ 'expanded' ] ; $ multiple = $ this -> options [ 'multiple' ] ; if ( $ multiple ) { $ this -> options [ 'attr' ] [ 'multiple' ] = true ; } if ( $ expanded && ! $ multiple ) { return $ this -> choiceType = 'radio' ; } if ( $ expanded && $ mult... | Determine which choice type to use . |
42,561 | protected function createChildren ( ) { if ( ( $ data_override = $ this -> getOption ( 'data_override' ) ) && $ data_override instanceof \ Closure ) { $ this -> options [ 'choices' ] = $ data_override ( $ this -> options [ 'choices' ] , $ this ) ; } $ this -> children = [ ] ; $ this -> determineChoiceField ( ) ; $ fiel... | Create children depending on choice type . |
42,562 | protected function buildSelect ( $ fieldType ) { $ this -> children [ ] = new $ fieldType ( $ this -> name , $ this -> choiceType , $ this -> parent , $ this -> formHelper -> mergeOptions ( $ this -> options , [ 'is_child' => true ] ) ) ; } | Build select field from choice . |
42,563 | public function alterValid ( Form $ mainForm , & $ isValid ) { $ this -> parent -> getFormHelper ( ) -> alterValid ( $ this -> form , $ mainForm , $ isValid ) ; } | Allow form - specific valid alters . |
42,564 | protected function parseFields ( $ fields ) { $ fieldsArray = explode ( ',' , $ fields ) ; $ text = '$this' . "\n" ; foreach ( $ fieldsArray as $ field ) { $ text .= $ this -> prepareAdd ( $ field , end ( $ fieldsArray ) == $ field ) ; } return $ text . ';' ; } | Parse fields from string . |
42,565 | protected function prepareAdd ( $ field , $ isLast = false ) { $ field = trim ( $ field ) ; list ( $ name , $ type ) = explode ( ':' , $ field ) ; $ textArr = [ " ->add('" , $ name , "', '" , $ type , "')" , ( $ isLast ) ? "" : "\n" ] ; return join ( '' , $ textArr ) ; } | Prepare template for single add field . |
42,566 | private function stripBase64 ( $ input ) { $ decoded = base64_decode ( $ input ) ; $ decoded = $ this -> stripTags ( $ decoded ) ; $ decoded = $ this -> stripEncodedEntities ( $ decoded ) ; $ output = base64_encode ( $ decoded ) ; return $ output ; } | Focuses on stripping entities from Base64 encoded strings |
42,567 | public function prepareAttributes ( $ options ) { if ( ! $ options ) { return null ; } $ attributes = [ ] ; foreach ( $ options as $ name => $ option ) { if ( $ option !== null ) { $ name = is_numeric ( $ name ) ? $ option : $ name ; $ attributes [ ] = $ name . '="' . $ option . '" ' ; } } return join ( '' , $ attribut... | Convert array of attributes to html attributes . |
42,568 | private function loadCustomTypes ( ) { $ customFields = ( array ) $ this -> getConfig ( 'custom_fields' ) ; if ( ! empty ( $ customFields ) ) { foreach ( $ customFields as $ fieldName => $ fieldClass ) { $ this -> addCustomField ( $ fieldName , $ fieldClass ) ; } } } | Load custom field types from config file . |
42,569 | public function formatLabel ( $ name ) { if ( ! $ name ) { return null ; } if ( $ this -> translator -> has ( $ name ) ) { $ translatedName = $ this -> translator -> get ( $ name ) ; if ( is_string ( $ translatedName ) ) { return $ translatedName ; } } return ucfirst ( str_replace ( '_' , ' ' , $ name ) ) ; } | Format the label to the proper format . |
42,570 | public function alterFieldValues ( Form $ form , array & $ values ) { $ form -> alterFieldValues ( $ values ) ; foreach ( $ form -> getFields ( ) as $ name => $ field ) { if ( method_exists ( $ field , 'alterFieldValues' ) ) { $ fullName = $ this -> transformToDotSyntax ( $ name ) ; $ subValues = ( array ) Arr :: get (... | Alter a form s values recursively according to its fields . |
42,571 | public function alterValid ( Form $ form , Form $ mainForm , & $ isValid ) { $ messages = $ form -> alterValid ( $ mainForm , $ isValid ) ; if ( $ messages ) { $ messageBag = $ mainForm -> getValidator ( ) -> getMessageBag ( ) ; $ this -> appendMessagesWithPrefix ( $ messageBag , $ form -> getName ( ) , $ messages ) ; ... | Alter a form s validity recursively and add messages with nested form prefix . |
42,572 | public function appendMessagesWithPrefix ( MessageBag $ messageBag , $ prefix , array $ keyedMessages ) { foreach ( $ keyedMessages as $ key => $ messages ) { if ( $ prefix ) { $ key = $ this -> transformToDotSyntax ( $ prefix . '[' . $ key . ']' ) ; } foreach ( ( array ) $ messages as $ message ) { $ messageBag -> add... | Add unprefixed messages with prefix to a MessageBag . |
42,573 | public function checkFieldName ( $ name , $ className ) { if ( ! $ name || trim ( $ name ) == '' ) { throw new \ InvalidArgumentException ( "Please provide valid field name for class [{$className}]" ) ; } if ( in_array ( $ name , static :: $ reservedFieldNames ) ) { throw new \ InvalidArgumentException ( "Field name [{... | Check if field name is valid and not reserved . |
42,574 | protected function setupChild ( FormField $ field , $ name , $ value = null ) { $ newFieldName = $ field -> getName ( ) . $ name ; $ firstFieldOptions = $ this -> formHelper -> mergeOptions ( $ this -> getOption ( 'options' ) , [ 'attr' => [ 'id' => $ newFieldName ] ] ) ; $ field -> setName ( $ newFieldName ) ; $ field... | Set up a single child element for a collection . |
42,575 | protected function generatePrototype ( FormField $ field ) { $ value = $ field instanceof ChildFormType ? false : null ; $ field -> setOption ( 'is_prototype' , true ) ; $ field = $ this -> setupChild ( $ field , $ this -> getPrototypeName ( ) , $ value ) ; if ( $ field instanceof ChildFormType ) { foreach ( $ field ->... | Generate prototype for regular form field . |
42,576 | public function preparePrototype ( FormField $ field ) { if ( ! $ field -> getOption ( 'is_prototype' ) ) { throw new \ InvalidArgumentException ( 'Field [' . $ field -> getRealName ( ) . '] is not a valid prototype object.' ) ; } $ this -> children = [ ] ; $ this -> children [ ] = $ field ; } | Prepare collection for prototype by adding prototype as child . |
42,577 | public function rebuildForm ( ) { $ this -> rebuilding = true ; if ( get_class ( $ this ) === 'Kris\LaravelFormBuilder\Form' ) { foreach ( $ this -> fields as $ name => $ field ) { $ options = Arr :: except ( $ field -> getOptions ( ) , 'tmp' ) ; $ this -> add ( $ name , $ field -> getType ( ) , $ options ) ; } } else ... | Rebuild the form from scratch . |
42,578 | protected function makeField ( $ name , $ type = 'text' , array $ options = [ ] ) { $ this -> setupFieldOptions ( $ name , $ options ) ; $ fieldName = $ this -> getFieldName ( $ name ) ; $ fieldType = $ this -> getFieldType ( $ type ) ; $ field = new $ fieldType ( $ fieldName , $ type , $ this , $ options ) ; $ this ->... | Create the FormField object . |
42,579 | public function add ( $ name , $ type = 'text' , array $ options = [ ] , $ modify = false ) { $ this -> formHelper -> checkFieldName ( $ name , get_class ( $ this ) ) ; if ( $ this -> rebuilding && ! $ this -> has ( $ name ) ) { return $ this ; } $ this -> addField ( $ this -> makeField ( $ name , $ type , $ options ) ... | Create a new field and add it to the form . |
42,580 | public function modify ( $ name , $ type = 'text' , array $ options = [ ] , $ overwriteOptions = false ) { if ( $ overwriteOptions === false && $ this -> has ( $ name ) ) { $ options = $ this -> formHelper -> mergeOptions ( $ this -> getField ( $ name ) -> getOptions ( ) , $ options ) ; } return $ this -> add ( $ name ... | Modify existing field . If it doesn t exist it is added to form . |
42,581 | public function renderForm ( array $ options = [ ] , $ showStart = true , $ showFields = true , $ showEnd = true ) { return $ this -> render ( $ options , $ this -> fields , $ showStart , $ showFields , $ showEnd ) ; } | Render full form . |
42,582 | public function renderRest ( $ showFormEnd = true , $ showFields = true ) { $ fields = $ this -> getUnrenderedFields ( ) ; return $ this -> render ( [ ] , $ fields , false , $ showFields , $ showFormEnd ) ; } | Render rest of the form . |
42,583 | public function getField ( $ name ) { if ( $ this -> has ( $ name ) ) { return $ this -> fields [ $ name ] ; } $ this -> fieldDoesNotExist ( $ name ) ; } | Get single field instance from form object . |
42,584 | public function getConfig ( $ key = null , $ default = null ) { return $ this -> formHelper -> getConfig ( $ key , $ default , $ this -> formConfig ) ; } | Get the passed config key using the custom form config if any . |
42,585 | protected function pullFromOptions ( $ name , $ method ) { if ( Arr :: get ( $ this -> formOptions , $ name ) !== null ) { $ this -> { $ method } ( Arr :: pull ( $ this -> formOptions , $ name ) ) ; } } | Get an option from provided options and call method with that value . |
42,586 | public function setName ( $ name , $ rebuild = true ) { $ this -> name = $ name ; if ( $ rebuild ) { $ this -> rebuildForm ( ) ; } return $ this ; } | Set the name of the form . |
42,587 | protected function getUnrenderedFields ( ) { $ unrenderedFields = [ ] ; foreach ( $ this -> fields as $ field ) { if ( ! $ field -> isRendered ( ) ) { $ unrenderedFields [ ] = $ field ; continue ; } } return $ unrenderedFields ; } | Get all fields that are not rendered . |
42,588 | protected function checkIfNamedForm ( ) { if ( $ this -> getFormOption ( 'name' ) ) { $ this -> name = Arr :: pull ( $ this -> formOptions , 'name' , $ this -> name ) ; } } | Check if form is named form . |
42,589 | protected function setupNamedModel ( ) { if ( ! $ this -> getModel ( ) || ! $ this -> getName ( ) ) { return false ; } $ dotName = $ this -> formHelper -> transformToDotSyntax ( $ this -> getName ( ) ) ; $ model = $ this -> formHelper -> convertModelToArray ( $ this -> getModel ( ) ) ; $ isCollectionFormModel = ( bool ... | Set namespace to model if form is named so the data is bound properly . Returns true if model is changed otherwise false . |
42,590 | public function getRules ( $ overrideRules = [ ] ) { $ fieldRules = $ this -> formHelper -> mergeFieldsRules ( $ this -> fields ) ; return array_merge ( $ fieldRules -> getRules ( ) , $ overrideRules ) ; } | Get validation rules for the form . |
42,591 | public function redirectIfNotValid ( $ destination = null ) { if ( ! $ this -> isValid ( ) ) { $ response = redirect ( $ destination ) ; if ( is_null ( $ destination ) ) { $ response = $ response -> back ( ) ; } $ response = $ response -> withErrors ( $ this -> getErrors ( ) , $ this -> getErrorBag ( ) ) -> withInput (... | Redirects to a destination when form is invalid . |
42,592 | public function isValid ( ) { if ( ! $ this -> validator ) { $ this -> validate ( ) ; } $ isValid = ! $ this -> validator -> fails ( ) ; $ this -> formHelper -> alterValid ( $ this , $ this , $ isValid ) ; $ this -> eventDispatcher -> dispatch ( new AfterFormValidation ( $ this , $ this -> validator , $ isValid ) ) ; r... | Check if the form is valid . |
42,593 | public function getErrors ( ) { if ( ! $ this -> validator || ! $ this -> validator instanceof Validator ) { throw new \ InvalidArgumentException ( sprintf ( 'Form %s was not validated. To validate it, call "isValid" method before retrieving the errors' , get_class ( $ this ) ) ) ; } return $ this -> validator -> getMe... | Get validation errors . |
42,594 | public function getFieldValues ( $ with_nulls = true ) { $ request_values = $ this -> getRequest ( ) -> all ( ) ; $ values = [ ] ; foreach ( $ this -> getAllAttributes ( ) as $ attribute ) { $ value = Arr :: get ( $ request_values , $ attribute ) ; if ( $ with_nulls || $ value !== null ) { Arr :: set ( $ values , $ att... | Get all Request values from all fields and nothing else . |
42,595 | public function getFilters ( ) { $ filters = [ ] ; foreach ( $ this -> getFields ( ) as $ field ) { $ filters [ $ field -> getName ( ) ] = $ field -> getFilters ( ) ; } return $ filters ; } | Method getFilters used to return array of all binded filters to form fields . |
42,596 | public function plain ( array $ options = [ ] , array $ data = [ ] ) { $ form = $ this -> setDependenciesAndOptions ( $ this -> container -> make ( $ this -> plainFormClass ) , $ options , $ data ) ; $ this -> eventDispatcher -> dispatch ( new AfterFormCreation ( $ form ) ) ; $ form -> filterFields ( ) ; return $ form ... | Get instance of the empty form which can be modified . |
42,597 | public function setDependenciesAndOptions ( $ instance , array $ options = [ ] , array $ data = [ ] ) { return $ instance -> addData ( $ data ) -> setRequest ( $ this -> container -> make ( 'request' ) ) -> setFormHelper ( $ this -> formHelper ) -> setEventDispatcher ( $ this -> eventDispatcher ) -> setFormBuilder ( $ ... | Set depedencies and options on existing form instance |
42,598 | protected function pluck ( $ value , $ key , $ data ) { if ( ! is_object ( $ data ) ) { return $ data ; } if ( method_exists ( $ data , 'pluck' ) || $ data instanceof Model ) { return $ data -> pluck ( $ value , $ key ) ; } elseif ( method_exists ( $ data , 'lists' ) ) { return $ data -> lists ( $ value , $ key ) ; } } | Pluck data . |
42,599 | private function configureContext ( Context $ context ) { foreach ( $ this -> attributes as $ key => $ value ) { $ context -> setAttribute ( $ key , $ value ) ; } if ( ! empty ( $ this -> groups ) ) { $ context -> setGroups ( $ this -> groups ) ; } if ( ( $ context instanceof SerializationContext ) && $ this -> seriali... | Configures context according to configuration |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.