repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Adldap2/Adldap2
src/Models/User.php
User.isExpired
public function isExpired(DateTime $date = null) { // Here we'll determine if the account expires by checking is expiration date. if ($expirationDate = $this->expirationDate()) { $date = $date ?: new DateTime(); return $expirationDate <= $date; } // The acco...
php
public function isExpired(DateTime $date = null) { // Here we'll determine if the account expires by checking is expiration date. if ($expirationDate = $this->expirationDate()) { $date = $date ?: new DateTime(); return $expirationDate <= $date; } // The acco...
[ "public", "function", "isExpired", "(", "DateTime", "$", "date", "=", "null", ")", "{", "// Here we'll determine if the account expires by checking is expiration date.", "if", "(", "$", "expirationDate", "=", "$", "this", "->", "expirationDate", "(", ")", ")", "{", ...
Return true / false if the LDAP User is expired. @param DateTime $date Optional date @return bool
[ "Return", "true", "/", "false", "if", "the", "LDAP", "User", "is", "expired", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/User.php#L923-L934
Adldap2/Adldap2
src/Models/User.php
User.expirationDate
public function expirationDate() { $accountExpiry = $this->getAccountExpiry(); // If the account expiry is zero or the expiry is equal to // ActiveDirectory's 'never expire' value, // then we'll return null here. if ($accountExpiry == 0 || $accountExpiry == $this->getSchema(...
php
public function expirationDate() { $accountExpiry = $this->getAccountExpiry(); // If the account expiry is zero or the expiry is equal to // ActiveDirectory's 'never expire' value, // then we'll return null here. if ($accountExpiry == 0 || $accountExpiry == $this->getSchema(...
[ "public", "function", "expirationDate", "(", ")", "{", "$", "accountExpiry", "=", "$", "this", "->", "getAccountExpiry", "(", ")", ";", "// If the account expiry is zero or the expiry is equal to", "// ActiveDirectory's 'never expire' value,", "// then we'll return null here.", ...
Return the expiration date of the user account. @return DateTime|null @throws \Exception
[ "Return", "the", "expiration", "date", "of", "the", "user", "account", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/User.php#L943-L957
Adldap2/Adldap2
src/Models/User.php
User.passwordExpired
public function passwordExpired() { // First we'll check the users userAccountControl to see if // it contains the 'password does not expire' flag. if ($this->getUserAccountControlObject()->has(AccountControl::DONT_EXPIRE_PASSWORD)) { return false; } $lastSet = (...
php
public function passwordExpired() { // First we'll check the users userAccountControl to see if // it contains the 'password does not expire' flag. if ($this->getUserAccountControlObject()->has(AccountControl::DONT_EXPIRE_PASSWORD)) { return false; } $lastSet = (...
[ "public", "function", "passwordExpired", "(", ")", "{", "// First we'll check the users userAccountControl to see if", "// it contains the 'password does not expire' flag.", "if", "(", "$", "this", "->", "getUserAccountControlObject", "(", ")", "->", "has", "(", "AccountControl...
Returns true / false if the users password is expired. @return bool
[ "Returns", "true", "/", "false", "if", "the", "users", "password", "is", "expired", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/User.php#L974-L1022
Adldap2/Adldap2
src/Models/RootDse.php
RootDse.getCurrentTime
public function getCurrentTime() { $time = $this->getFirstAttribute($this->schema->currentTime()); return DateTime::createFromFormat($this->timestampFormat, $time)->getTimestamp(); }
php
public function getCurrentTime() { $time = $this->getFirstAttribute($this->schema->currentTime()); return DateTime::createFromFormat($this->timestampFormat, $time)->getTimestamp(); }
[ "public", "function", "getCurrentTime", "(", ")", "{", "$", "time", "=", "$", "this", "->", "getFirstAttribute", "(", "$", "this", "->", "schema", "->", "currentTime", "(", ")", ")", ";", "return", "DateTime", "::", "createFromFormat", "(", "$", "this", ...
Returns the hosts current time in unix timestamp format. @return int
[ "Returns", "the", "hosts", "current", "time", "in", "unix", "timestamp", "format", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/RootDse.php#L21-L26
Adldap2/Adldap2
src/Query/Processor.php
Processor.process
public function process($results) { // Normalize entries. Get entries returns false on failure. // We'll always want an array in this situation. $entries = $this->connection->getEntries($results) ?: []; if ($this->builder->isRaw()) { // If the builder is asking for a raw...
php
public function process($results) { // Normalize entries. Get entries returns false on failure. // We'll always want an array in this situation. $entries = $this->connection->getEntries($results) ?: []; if ($this->builder->isRaw()) { // If the builder is asking for a raw...
[ "public", "function", "process", "(", "$", "results", ")", "{", "// Normalize entries. Get entries returns false on failure.", "// We'll always want an array in this situation.", "$", "entries", "=", "$", "this", "->", "connection", "->", "getEntries", "(", "$", "results", ...
Processes LDAP search results and constructs their model instances. @param resource $results @return Collection|array
[ "Processes", "LDAP", "search", "results", "and", "constructs", "their", "model", "instances", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L48-L83
Adldap2/Adldap2
src/Query/Processor.php
Processor.processPaginated
public function processPaginated(array $pages = [], $perPage = 50, $currentPage = 0) { $models = []; foreach ($pages as $results) { // Go through each page and process the results into an objects array. $models = array_merge($models, $this->process($results)); } ...
php
public function processPaginated(array $pages = [], $perPage = 50, $currentPage = 0) { $models = []; foreach ($pages as $results) { // Go through each page and process the results into an objects array. $models = array_merge($models, $this->process($results)); } ...
[ "public", "function", "processPaginated", "(", "array", "$", "pages", "=", "[", "]", ",", "$", "perPage", "=", "50", ",", "$", "currentPage", "=", "0", ")", "{", "$", "models", "=", "[", "]", ";", "foreach", "(", "$", "pages", "as", "$", "results",...
Processes paginated LDAP results. @param array $pages @param int $perPage @param int $currentPage @return Paginator
[ "Processes", "paginated", "LDAP", "results", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L94-L106
Adldap2/Adldap2
src/Query/Processor.php
Processor.newLdapEntry
public function newLdapEntry(array $attributes = []) { $objectClass = $this->schema->objectClass(); if (array_key_exists($objectClass, $attributes) && array_key_exists(0, $attributes[$objectClass])) { // Retrieve all of the object classes from the LDAP // entry and lowercase...
php
public function newLdapEntry(array $attributes = []) { $objectClass = $this->schema->objectClass(); if (array_key_exists($objectClass, $attributes) && array_key_exists(0, $attributes[$objectClass])) { // Retrieve all of the object classes from the LDAP // entry and lowercase...
[ "public", "function", "newLdapEntry", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "objectClass", "=", "$", "this", "->", "schema", "->", "objectClass", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "objectClass", ",", "$", ...
Returns a new LDAP Entry instance. @param array $attributes @return Entry
[ "Returns", "a", "new", "LDAP", "Entry", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L115-L145
Adldap2/Adldap2
src/Query/Processor.php
Processor.newModel
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 class...
php
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 class...
[ "public", "function", "newModel", "(", "$", "attributes", "=", "[", "]", ",", "$", "model", "=", "null", ")", "{", "$", "model", "=", "(", "class_exists", "(", "$", "model", ")", "?", "$", "model", ":", "$", "this", "->", "schema", "->", "entryMode...
Creates a new model instance. @param array $attributes @param string|null $model @throws InvalidArgumentException @return mixed|Entry
[ "Creates", "a", "new", "model", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L157-L166
Adldap2/Adldap2
src/Query/Processor.php
Processor.newPaginator
public function newPaginator(array $models = [], $perPage = 25, $currentPage = 0, $pages = 1) { return new Paginator($models, $perPage, $currentPage, $pages); }
php
public function newPaginator(array $models = [], $perPage = 25, $currentPage = 0, $pages = 1) { return new Paginator($models, $perPage, $currentPage, $pages); }
[ "public", "function", "newPaginator", "(", "array", "$", "models", "=", "[", "]", ",", "$", "perPage", "=", "25", ",", "$", "currentPage", "=", "0", ",", "$", "pages", "=", "1", ")", "{", "return", "new", "Paginator", "(", "$", "models", ",", "$", ...
Returns a new Paginator object instance. @param array $models @param int $perPage @param int $currentPage @param int $pages @return Paginator
[ "Returns", "a", "new", "Paginator", "object", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L178-L181
Adldap2/Adldap2
src/Query/Processor.php
Processor.processSort
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($model...
php
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($model...
[ "protected", "function", "processSort", "(", "array", "$", "models", "=", "[", "]", ")", "{", "$", "field", "=", "$", "this", "->", "builder", "->", "getSortByField", "(", ")", ";", "$", "flags", "=", "$", "this", "->", "builder", "->", "getSortByFlags...
Sorts LDAP search results. @param array $models @return Collection
[ "Sorts", "LDAP", "search", "results", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Query/Processor.php#L202-L213
Adldap2/Adldap2
src/Models/Factory.php
Factory.entry
public function entry(array $attributes = []) { $model = $this->schema->entryModel(); return (new $model($attributes, $this->query)); }
php
public function entry(array $attributes = []) { $model = $this->schema->entryModel(); return (new $model($attributes, $this->query)); }
[ "public", "function", "entry", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "entryModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", "this"...
Creates a new generic LDAP entry instance. @param array $attributes @return Entry
[ "Creates", "a", "new", "generic", "LDAP", "entry", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L80-L85
Adldap2/Adldap2
src/Models/Factory.php
Factory.user
public function user(array $attributes = []) { $model = $this->schema->userModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), $this->schema->userObjectClasses()); }
php
public function user(array $attributes = []) { $model = $this->schema->userModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), $this->schema->userObjectClasses()); }
[ "public", "function", "user", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "userModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", "this", ...
Creates a new user instance. @param array $attributes @return User
[ "Creates", "a", "new", "user", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L94-L100
Adldap2/Adldap2
src/Models/Factory.php
Factory.ou
public function ou(array $attributes = []) { $model = $this->schema->organizationalUnitModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), [ $this->schema->top(), $this->schema->organizationalUnit(), ...
php
public function ou(array $attributes = []) { $model = $this->schema->organizationalUnitModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), [ $this->schema->top(), $this->schema->organizationalUnit(), ...
[ "public", "function", "ou", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "organizationalUnitModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$"...
Creates a new organizational unit instance. @param array $attributes @return OrganizationalUnit
[ "Creates", "a", "new", "organizational", "unit", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L109-L118
Adldap2/Adldap2
src/Models/Factory.php
Factory.group
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(), ]);...
php
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(), ]);...
[ "public", "function", "group", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "groupModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", "this"...
Creates a new group instance. @param array $attributes @return Group
[ "Creates", "a", "new", "group", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L127-L136
Adldap2/Adldap2
src/Models/Factory.php
Factory.container
public function container(array $attributes = []) { $model = $this->schema->containerModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), $this->schema->objectClassContainer()); }
php
public function container(array $attributes = []) { $model = $this->schema->containerModel(); return (new $model($attributes, $this->query)) ->setAttribute($this->schema->objectClass(), $this->schema->objectClassContainer()); }
[ "public", "function", "container", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "containerModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", ...
Creates a new organizational unit instance. @param array $attributes @return Container
[ "Creates", "a", "new", "organizational", "unit", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L145-L151
Adldap2/Adldap2
src/Models/Factory.php
Factory.contact
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->s...
php
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->s...
[ "public", "function", "contact", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "contactModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", "t...
Creates a new user instance as a contact. @param array $attributes @return User
[ "Creates", "a", "new", "user", "instance", "as", "a", "contact", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L160-L171
Adldap2/Adldap2
src/Models/Factory.php
Factory.computer
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-...
php
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-...
[ "public", "function", "computer", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "schema", "->", "computerModel", "(", ")", ";", "return", "(", "new", "$", "model", "(", "$", "attributes", ",", "$", ...
Creates a new computer instance. @param array $attributes @return Computer
[ "Creates", "a", "new", "computer", "instance", "." ]
train
https://github.com/Adldap2/Adldap2/blob/a6089f508b2a94cb7ff8c98ab381ff983d5f0347/src/Models/Factory.php#L180-L192
musonza/chat
src/ChatServiceProvider.php
ChatServiceProvider.registerChat
private function registerChat() { $this->app->bind('chat', function () { return $this->app->make(\Musonza\Chat\Chat::class); }); }
php
private function registerChat() { $this->app->bind('chat', function () { return $this->app->make(\Musonza\Chat\Chat::class); }); }
[ "private", "function", "registerChat", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'chat'", ",", "function", "(", ")", "{", "return", "$", "this", "->", "app", "->", "make", "(", "\\", "Musonza", "\\", "Chat", "\\", "Chat", "::", "...
Registers Chat. @return void
[ "Registers", "Chat", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/ChatServiceProvider.php#L42-L47
musonza/chat
src/ChatServiceProvider.php
ChatServiceProvider.publishMigrations
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], 'cha...
php
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], 'cha...
[ "public", "function", "publishMigrations", "(", ")", "{", "$", "timestamp", "=", "date", "(", "'Y_m_d_His'", ",", "time", "(", ")", ")", ";", "$", "stub", "=", "__DIR__", ".", "'/../database/migrations/create_chat_tables.php'", ";", "$", "target", "=", "$", ...
Publish package's migrations. @return void
[ "Publish", "package", "s", "migrations", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/ChatServiceProvider.php#L54-L61
musonza/chat
src/Models/Conversation.php
Conversation.getMessages
public function getMessages($user, $paginationParams, $deleted = false) { return $this->getConversationMessages($user, $paginationParams, $deleted); }
php
public function getMessages($user, $paginationParams, $deleted = false) { return $this->getConversationMessages($user, $paginationParams, $deleted); }
[ "public", "function", "getMessages", "(", "$", "user", ",", "$", "paginationParams", ",", "$", "deleted", "=", "false", ")", "{", "return", "$", "this", "->", "getConversationMessages", "(", "$", "user", ",", "$", "paginationParams", ",", "$", "deleted", "...
Get messages for a conversation. @param User $user @param array $paginationParams @param bool $deleted @return Message
[ "Get", "messages", "for", "a", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L55-L58
musonza/chat
src/Models/Conversation.php
Conversation.getList
public function getList($user, $perPage = 25, $page = 1, $pageName = 'page') { return $this->getConversationsList($user, $perPage, $page, $pageName); }
php
public function getList($user, $perPage = 25, $page = 1, $pageName = 'page') { return $this->getConversationsList($user, $perPage, $page, $pageName); }
[ "public", "function", "getList", "(", "$", "user", ",", "$", "perPage", "=", "25", ",", "$", "page", "=", "1", ",", "$", "pageName", "=", "'page'", ")", "{", "return", "$", "this", "->", "getConversationsList", "(", "$", "user", ",", "$", "perPage", ...
Gets the list of conversations. @deprecated This will be deprecated in 4.0 @param User $user The user @param int $perPage The per page @param int $page The page @param string $pageName The page name @return Conversations The list.
[ "Gets", "the", "list", "of", "conversations", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L72-L75
musonza/chat
src/Models/Conversation.php
Conversation.addParticipants
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()-...
php
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()-...
[ "public", "function", "addParticipants", "(", "$", "userIds", ")", "{", "if", "(", "is_array", "(", "$", "userIds", ")", ")", "{", "foreach", "(", "$", "userIds", "as", "$", "id", ")", "{", "$", "this", "->", "users", "(", ")", "->", "attach", "(",...
Add user to conversation. @param int $userId @return void
[ "Add", "user", "to", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L95-L111
musonza/chat
src/Models/Conversation.php
Conversation.removeUsers
public function removeUsers($users) { if (is_array($users)) { foreach ($users as $id) { $this->users()->detach($id); } return $this; } $this->users()->detach($users); return $this; }
php
public function removeUsers($users) { if (is_array($users)) { foreach ($users as $id) { $this->users()->detach($id); } return $this; } $this->users()->detach($users); return $this; }
[ "public", "function", "removeUsers", "(", "$", "users", ")", "{", "if", "(", "is_array", "(", "$", "users", ")", ")", "{", "foreach", "(", "$", "users", "as", "$", "id", ")", "{", "$", "this", "->", "users", "(", ")", "->", "detach", "(", "$", ...
Remove user from conversation. @param $users @return Conversation
[ "Remove", "user", "from", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L120-L133
musonza/chat
src/Models/Conversation.php
Conversation.start
public function start($participants, $data = []) { $conversation = $this->create(['data' => $data]); if ($participants) { $conversation->addParticipants($participants); } return $conversation; }
php
public function start($participants, $data = []) { $conversation = $this->create(['data' => $data]); if ($participants) { $conversation->addParticipants($participants); } return $conversation; }
[ "public", "function", "start", "(", "$", "participants", ",", "$", "data", "=", "[", "]", ")", "{", "$", "conversation", "=", "$", "this", "->", "create", "(", "[", "'data'", "=>", "$", "data", "]", ")", ";", "if", "(", "$", "participants", ")", ...
Starts a new conversation. @param array $participants users @return Conversation
[ "Starts", "a", "new", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L142-L151
musonza/chat
src/Models/Conversation.php
Conversation.userConversations
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',...
php
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',...
[ "public", "function", "userConversations", "(", "$", "user", ")", "{", "$", "userId", "=", "is_object", "(", "$", "user", ")", "?", "$", "user", "->", "getKey", "(", ")", ":", "$", "user", ";", "return", "$", "this", "->", "join", "(", "'mc_conversat...
Gets conversations for a specific user. @param User | int $user @return array
[ "Gets", "conversations", "for", "a", "specific", "user", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L185-L193
musonza/chat
src/Models/Conversation.php
Conversation.unReadNotifications
public function unReadNotifications($user) { $notifications = MessageNotification::where([['user_id', '=', $user->getKey()], ['conversation_id', '=', $this->id], ['is_seen', '=', 0]])->get(); return $notifications; }
php
public function unReadNotifications($user) { $notifications = MessageNotification::where([['user_id', '=', $user->getKey()], ['conversation_id', '=', $this->id], ['is_seen', '=', 0]])->get(); return $notifications; }
[ "public", "function", "unReadNotifications", "(", "$", "user", ")", "{", "$", "notifications", "=", "MessageNotification", "::", "where", "(", "[", "[", "'user_id'", ",", "'='", ",", "$", "user", "->", "getKey", "(", ")", "]", ",", "[", "'conversation_id'"...
Get unread notifications. @param User $user @return void
[ "Get", "unread", "notifications", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L202-L207
musonza/chat
src/Models/Conversation.php
Conversation.common
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) { $...
php
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) { $...
[ "public", "function", "common", "(", "$", "users", ")", "{", "if", "(", "$", "users", "instanceof", "\\", "Illuminate", "\\", "Database", "\\", "Eloquent", "\\", "Collection", ")", "{", "$", "users", "=", "$", "users", "->", "map", "(", "function", "("...
Gets conversations that are common for a list of users. @param \Illuminate\Database\Eloquent\Collection | array $users ids @return \Illuminate\Database\Eloquent\Collection Conversation
[ "Gets", "conversations", "that", "are", "common", "for", "a", "list", "of", "users", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Conversation.php#L216-L229
musonza/chat
src/Messages/SendMessageCommandHandler.php
SendMessageCommandHandler.handle
public function handle($command) { $message = $this->message->send($command->conversation, $command->body, $command->senderId, $command->type); $this->dispatcher->dispatch($this->message->releaseEvents()); return $message; }
php
public function handle($command) { $message = $this->message->send($command->conversation, $command->body, $command->senderId, $command->type); $this->dispatcher->dispatch($this->message->releaseEvents()); return $message; }
[ "public", "function", "handle", "(", "$", "command", ")", "{", "$", "message", "=", "$", "this", "->", "message", "->", "send", "(", "$", "command", "->", "conversation", ",", "$", "command", "->", "body", ",", "$", "command", "->", "senderId", ",", ...
Triggers sending the message. @param $command The command @return Message
[ "Triggers", "sending", "the", "message", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Messages/SendMessageCommandHandler.php#L31-L38
musonza/chat
src/Services/MessageService.php
MessageService.send
public function send() { if (!$this->from) { throw new \Exception('Message sender has not been set'); } if (!$this->body) { throw new \Exception('Message body has not been set'); } if (!$this->to) { throw new \Exception('Message receiver ...
php
public function send() { if (!$this->from) { throw new \Exception('Message sender has not been set'); } if (!$this->body) { throw new \Exception('Message body has not been set'); } if (!$this->to) { throw new \Exception('Message receiver ...
[ "public", "function", "send", "(", ")", "{", "if", "(", "!", "$", "this", "->", "from", ")", "{", "throw", "new", "\\", "Exception", "(", "'Message sender has not been set'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "body", ")", "{", "throw"...
Sends the message. @return void
[ "Sends", "the", "message", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Services/MessageService.php#L98-L115
musonza/chat
database/migrations/create_chat_tables.php
CreateChatTables.up
public function up() { Schema::create('mc_conversations', function (Blueprint $table) { $table->increments('id'); $table->boolean('private')->default(true); $table->text('data')->nullable(); $table->timestamps(); }); Schema::create('mc_message...
php
public function up() { Schema::create('mc_conversations', function (Blueprint $table) { $table->increments('id'); $table->boolean('private')->default(true); $table->text('data')->nullable(); $table->timestamps(); }); Schema::create('mc_message...
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "'mc_conversations'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "increments", "(", "'id'", ")", ";", "$", "table", "->", "boolean", "(", "'pr...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/database/migrations/create_chat_tables.php#L26-L96
musonza/chat
src/Models/Message.php
Message.send
public function send(Conversation $conversation, $body, $userId, $type = 'text') { $message = $conversation->messages()->create([ 'body' => $body, 'user_id' => $userId, 'type' => $type, ]); $messageWasSent = Chat::sentMessageEvent(); $message->loa...
php
public function send(Conversation $conversation, $body, $userId, $type = 'text') { $message = $conversation->messages()->create([ 'body' => $body, 'user_id' => $userId, 'type' => $type, ]); $messageWasSent = Chat::sentMessageEvent(); $message->loa...
[ "public", "function", "send", "(", "Conversation", "$", "conversation", ",", "$", "body", ",", "$", "userId", ",", "$", "type", "=", "'text'", ")", "{", "$", "message", "=", "$", "conversation", "->", "messages", "(", ")", "->", "create", "(", "[", "...
Adds a message to a conversation. @param Conversation $conversation @param string $body @param int $userId @param string $type @return Message
[ "Adds", "a", "message", "to", "a", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Message.php#L60-L73
musonza/chat
src/Models/Message.php
Message.trash
public function trash($user) { return MessageNotification::where('user_id', $user->getKey()) ->where('message_id', $this->id) ->delete(); }
php
public function trash($user) { return MessageNotification::where('user_id', $user->getKey()) ->where('message_id', $this->id) ->delete(); }
[ "public", "function", "trash", "(", "$", "user", ")", "{", "return", "MessageNotification", "::", "where", "(", "'user_id'", ",", "$", "user", "->", "getKey", "(", ")", ")", "->", "where", "(", "'message_id'", ",", "$", "this", "->", "id", ")", "->", ...
Deletes a message. @param Message $message @param User $user @return
[ "Deletes", "a", "message", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Message.php#L83-L88
musonza/chat
src/Models/Message.php
Message.getNotification
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(); }
php
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(); }
[ "public", "function", "getNotification", "(", "$", "user", ")", "{", "return", "MessageNotification", "::", "where", "(", "'user_id'", ",", "$", "user", "->", "getKey", "(", ")", ")", "->", "where", "(", "'message_id'", ",", "$", "this", "->", "id", ")",...
Return user notification for specific message. @param $user @return Notification
[ "Return", "user", "notification", "for", "specific", "message", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Models/Message.php#L97-L103
musonza/chat
src/Services/ConversationService.php
ConversationService.getMessages
public function getMessages() { return $this->conversation->getMessages($this->user, $this->getPaginationParams(), $this->deleted); }
php
public function getMessages() { return $this->conversation->getMessages($this->user, $this->getPaginationParams(), $this->deleted); }
[ "public", "function", "getMessages", "(", ")", "{", "return", "$", "this", "->", "conversation", "->", "getMessages", "(", "$", "this", "->", "user", ",", "$", "this", "->", "getPaginationParams", "(", ")", ",", "$", "this", "->", "deleted", ")", ";", ...
Get messages in a conversation. @return Message
[ "Get", "messages", "in", "a", "conversation", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Services/ConversationService.php#L43-L46
musonza/chat
src/Services/ConversationService.php
ConversationService.between
public function between($userOne, $userTwo) { $conversation1 = $this->conversation->userConversations($userOne)->toArray(); $conversation2 = $this->conversation->userConversations($userTwo)->toArray(); $common_conversations = $this->getConversationsInCommon($conversation1, $conversation2); ...
php
public function between($userOne, $userTwo) { $conversation1 = $this->conversation->userConversations($userOne)->toArray(); $conversation2 = $this->conversation->userConversations($userTwo)->toArray(); $common_conversations = $this->getConversationsInCommon($conversation1, $conversation2); ...
[ "public", "function", "between", "(", "$", "userOne", ",", "$", "userTwo", ")", "{", "$", "conversation1", "=", "$", "this", "->", "conversation", "->", "userConversations", "(", "$", "userOne", ")", "->", "toArray", "(", ")", ";", "$", "conversation2", ...
Get Private Conversation between two users. @param int | User $userOne @param int | User $userTwo @return Conversation
[ "Get", "Private", "Conversation", "between", "two", "users", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Services/ConversationService.php#L74-L86
musonza/chat
src/Services/ConversationService.php
ConversationService.get
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' =...
php
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' =...
[ "public", "function", "get", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "isPrivate", ")", ")", "{", "return", "$", "this", "->", "conversation", "->", "getList", "(", "$", "this", "->", "user", ",", "$", "this", "->", "perPage", "...
Get Conversations with lastest message. @param object $user @return Illuminate\Pagination\LengthAwarePaginator
[ "Get", "Conversations", "with", "lastest", "message", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Services/ConversationService.php#L107-L119
musonza/chat
src/Traits/SetsParticipants.php
SetsParticipants.from
public function from($from) { $this->from = is_object($from) ? $from->getKey() : $from; return $this; }
php
public function from($from) { $this->from = is_object($from) ? $from->getKey() : $from; return $this; }
[ "public", "function", "from", "(", "$", "from", ")", "{", "$", "this", "->", "from", "=", "is_object", "(", "$", "from", ")", "?", "$", "from", "->", "getKey", "(", ")", ":", "$", "from", ";", "return", "$", "this", ";", "}" ]
Set Sender. @param int $from @return $this
[ "Set", "Sender", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Traits/SetsParticipants.php#L46-L51
musonza/chat
src/Traits/Paginates.php
Paginates.page
public function page(int $page) { $this->page = $page ? $page : $this->page; return $this; }
php
public function page(int $page) { $this->page = $page ? $page : $this->page; return $this; }
[ "public", "function", "page", "(", "int", "$", "page", ")", "{", "$", "this", "->", "page", "=", "$", "page", "?", "$", "page", ":", "$", "this", "->", "page", ";", "return", "$", "this", ";", "}" ]
Set current page for pagination. @param int $page @return $this
[ "Set", "current", "page", "for", "pagination", "." ]
train
https://github.com/musonza/chat/blob/ce4e6f4aa46301a304d666fe5c4ef04b91e3825c/src/Traits/Paginates.php#L35-L40
egulias/EmailValidator
EmailValidator/EmailLexer.php
EmailLexer.getType
protected function getType(&$value) { if ($this->isNullType($value)) { return self::C_NUL; } if ($this->isValid($value)) { return $this->charValue[$value]; } if ($this->isUTF8Invalid($value)) { $this->hasInvalidTokens = true; ...
php
protected function getType(&$value) { if ($this->isNullType($value)) { return self::C_NUL; } if ($this->isValid($value)) { return $this->charValue[$value]; } if ($this->isUTF8Invalid($value)) { $this->hasInvalidTokens = true; ...
[ "protected", "function", "getType", "(", "&", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isNullType", "(", "$", "value", ")", ")", "{", "return", "self", "::", "C_NUL", ";", "}", "if", "(", "$", "this", "->", "isValid", "(", "$", "val...
Retrieve token type. Also processes the token value if necessary. @param string $value @throws \InvalidArgumentException @return integer
[ "Retrieve", "token", "type", ".", "Also", "processes", "the", "token", "value", "if", "necessary", "." ]
train
https://github.com/egulias/EmailValidator/blob/709f21f92707308cdf8f9bcfa1af4cb26586521e/EmailValidator/EmailLexer.php#L164-L180
egulias/EmailValidator
EmailValidator/Validation/MultipleValidationWithAnd.php
MultipleValidationWithAnd.isValid
public function isValid($email, EmailLexer $emailLexer) { $result = true; $errors = []; foreach ($this->validations as $validation) { $emailLexer->reset(); $validationResult = $validation->isValid($email, $emailLexer); $result = $result && $validationResul...
php
public function isValid($email, EmailLexer $emailLexer) { $result = true; $errors = []; foreach ($this->validations as $validation) { $emailLexer->reset(); $validationResult = $validation->isValid($email, $emailLexer); $result = $result && $validationResul...
[ "public", "function", "isValid", "(", "$", "email", ",", "EmailLexer", "$", "emailLexer", ")", "{", "$", "result", "=", "true", ";", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "validations", "as", "$", "validation", ")", "{...
{@inheritdoc}
[ "{" ]
train
https://github.com/egulias/EmailValidator/blob/709f21f92707308cdf8f9bcfa1af4cb26586521e/EmailValidator/Validation/MultipleValidationWithAnd.php#L59-L80
egulias/EmailValidator
EmailValidator/Parser/Parser.php
Parser.validateQuotedPair
protected function validateQuotedPair() { if (!($this->lexer->token['type'] === EmailLexer::INVALID || $this->lexer->token['type'] === EmailLexer::C_DEL)) { throw new ExpectedQPair(); } $this->warnings[QuotedPart::CODE] = new QuotedPart($this->lexer->getP...
php
protected function validateQuotedPair() { if (!($this->lexer->token['type'] === EmailLexer::INVALID || $this->lexer->token['type'] === EmailLexer::C_DEL)) { throw new ExpectedQPair(); } $this->warnings[QuotedPart::CODE] = new QuotedPart($this->lexer->getP...
[ "protected", "function", "validateQuotedPair", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "lexer", "->", "token", "[", "'type'", "]", "===", "EmailLexer", "::", "INVALID", "||", "$", "this", "->", "lexer", "->", "token", "[", "'type'", "]",...
validateQuotedPair
[ "validateQuotedPair" ]
train
https://github.com/egulias/EmailValidator/blob/709f21f92707308cdf8f9bcfa1af4cb26586521e/EmailValidator/Parser/Parser.php#L49-L58
egulias/EmailValidator
EmailValidator/Validation/NoRFCWarningsValidation.php
NoRFCWarningsValidation.isValid
public function isValid($email, EmailLexer $emailLexer) { if (!parent::isValid($email, $emailLexer)) { return false; } if (empty($this->getWarnings())) { return true; } $this->error = new RFCWarnings(); return false; }
php
public function isValid($email, EmailLexer $emailLexer) { if (!parent::isValid($email, $emailLexer)) { return false; } if (empty($this->getWarnings())) { return true; } $this->error = new RFCWarnings(); return false; }
[ "public", "function", "isValid", "(", "$", "email", ",", "EmailLexer", "$", "emailLexer", ")", "{", "if", "(", "!", "parent", "::", "isValid", "(", "$", "email", ",", "$", "emailLexer", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/egulias/EmailValidator/blob/709f21f92707308cdf8f9bcfa1af4cb26586521e/EmailValidator/Validation/NoRFCWarningsValidation.php#L19-L32
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
FormBuilderServiceProvider.register
public function register() { $this->commands('Kris\LaravelFormBuilder\Console\FormMakeCommand'); $this->registerHtmlIfNeeded(); $this->registerFormIfHeeded(); $this->mergeConfigFrom( __DIR__ . '/../../config/config.php', 'laravel-form-builder' ); ...
php
public function register() { $this->commands('Kris\LaravelFormBuilder\Console\FormMakeCommand'); $this->registerHtmlIfNeeded(); $this->registerFormIfHeeded(); $this->mergeConfigFrom( __DIR__ . '/../../config/config.php', 'laravel-form-builder' ); ...
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "commands", "(", "'Kris\\LaravelFormBuilder\\Console\\FormMakeCommand'", ")", ";", "$", "this", "->", "registerHtmlIfNeeded", "(", ")", ";", "$", "this", "->", "registerFormIfHeeded", "(", ")", ...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php#L22-L52
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
FormBuilderServiceProvider.registerFormHelper
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('la...
php
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('la...
[ "protected", "function", "registerFormHelper", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'laravel-form-helper'", ",", "function", "(", "$", "app", ")", "{", "$", "configuration", "=", "$", "app", "[", "'config'", "]", "->", "get", ...
Register the form helper. @return void
[ "Register", "the", "form", "helper", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php#L59-L69
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
FormBuilderServiceProvider.boot
public function boot() { $this->loadViewsFrom(__DIR__ . '/../../views', 'laravel-form-builder'); $this->publishes([ __DIR__ . '/../../views' => base_path('resources/views/vendor/laravel-form-builder'), __DIR__ . '/../../config/config.php' => config_path('laravel-form-builder...
php
public function boot() { $this->loadViewsFrom(__DIR__ . '/../../views', 'laravel-form-builder'); $this->publishes([ __DIR__ . '/../../views' => base_path('resources/views/vendor/laravel-form-builder'), __DIR__ . '/../../config/config.php' => config_path('laravel-form-builder...
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/../../views'", ",", "'laravel-form-builder'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../views'", "=>", "base_path", "(...
Bootstrap the service. @return void
[ "Bootstrap", "the", "service", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php#L76-L95
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
FormBuilderServiceProvider.registerFormIfHeeded
private function registerFormIfHeeded() { if (!$this->app->offsetExists('form')) { $this->app->singleton('form', function($app) { // LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exception $version = substr(Application::VERSION, ...
php
private function registerFormIfHeeded() { if (!$this->app->offsetExists('form')) { $this->app->singleton('form', function($app) { // LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exception $version = substr(Application::VERSION, ...
[ "private", "function", "registerFormIfHeeded", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "offsetExists", "(", "'form'", ")", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'form'", ",", "function", "(", "$", "app", ...
Add Laravel Form to container if not already set. @return void
[ "Add", "Laravel", "Form", "to", "container", "if", "not", "already", "set", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php#L112-L142
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
FormBuilderServiceProvider.registerHtmlIfNeeded
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::get...
php
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::get...
[ "private", "function", "registerHtmlIfNeeded", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "offsetExists", "(", "'html'", ")", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'html'", ",", "function", "(", "$", "app", ...
Add Laravel Html to container if not already set.
[ "Add", "Laravel", "Html", "to", "container", "if", "not", "already", "set", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php#L147-L163
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php
StripTags.setAllowedTags
public function setAllowedTags($allowedTags) { if (!is_array($allowedTags)) { $allowedTags = array($allowedTags); } foreach ($allowedTags as $index => $element) { // If the tag was provided without attributes if (is_int($index) && is_string($element)) { ...
php
public function setAllowedTags($allowedTags) { if (!is_array($allowedTags)) { $allowedTags = array($allowedTags); } foreach ($allowedTags as $index => $element) { // If the tag was provided without attributes if (is_int($index) && is_string($element)) { ...
[ "public", "function", "setAllowedTags", "(", "$", "allowedTags", ")", "{", "if", "(", "!", "is_array", "(", "$", "allowedTags", ")", ")", "{", "$", "allowedTags", "=", "array", "(", "$", "allowedTags", ")", ";", "}", "foreach", "(", "$", "allowedTags", ...
Sets the allowedTags property. @param array|string $allowedTags @return \Kris\LaravelFormBuilder\Filters\Collection\StripTags
[ "Sets", "the", "allowedTags", "property", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php#L58-L98
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php
StripTags.setAllowedAttributes
public function setAllowedAttributes($allowedAttribs) { if (!is_array($allowedAttribs)) { $allowedAttribs = [$allowedAttribs]; } // Store each attribute as allowed. foreach ($allowedAttribs as $attribute) { if (is_string($attribute)) { // Cano...
php
public function setAllowedAttributes($allowedAttribs) { if (!is_array($allowedAttribs)) { $allowedAttribs = [$allowedAttribs]; } // Store each attribute as allowed. foreach ($allowedAttribs as $attribute) { if (is_string($attribute)) { // Cano...
[ "public", "function", "setAllowedAttributes", "(", "$", "allowedAttribs", ")", "{", "if", "(", "!", "is_array", "(", "$", "allowedAttribs", ")", ")", "{", "$", "allowedAttribs", "=", "[", "$", "allowedAttribs", "]", ";", "}", "// Store each attribute as allowed....
Sets the allowedAttributes property. @param array|string $allowedAttribs @return \Kris\LaravelFormBuilder\Filters\Collection\StripTags
[ "Sets", "the", "allowedAttributes", "property", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php#L115-L131
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php
StripTags.filterCertainTag
public function filterCertainTag($tag) { // Parse the tag into: // 1. a starting delimiter (mandatory) // 2. a tag name (if available) // 3. a string of attributes (if available) // 4. an ending delimiter (if available) $isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>]...
php
public function filterCertainTag($tag) { // Parse the tag into: // 1. a starting delimiter (mandatory) // 2. a tag name (if available) // 3. a string of attributes (if available) // 4. an ending delimiter (if available) $isMatch = preg_match('~(</?)(\w*)((/(?!>)|[^/>]...
[ "public", "function", "filterCertainTag", "(", "$", "tag", ")", "{", "// Parse the tag into:", "// 1. a starting delimiter (mandatory)", "// 2. a tag name (if available)", "// 3. a string of attributes (if available)", "// 4. an ending delimiter (if available)", "$", "isMatch", "=", ...
Filters a single tag against the current property data. @param string $tag @return string
[ "Filters", "a", "single", "tag", "against", "the", "current", "property", "data", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/StripTags.php#L193-L253
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php
FormMakeCommand.replaceClass
protected function replaceClass($stub, $name) { $formGenerator = $this->formGenerator; $stub = str_replace( '{{class}}', $formGenerator->getClassInfo($name)->className, $stub ); return str_replace( '{{fields}}', $formGener...
php
protected function replaceClass($stub, $name) { $formGenerator = $this->formGenerator; $stub = str_replace( '{{class}}', $formGenerator->getClassInfo($name)->className, $stub ); return str_replace( '{{fields}}', $formGener...
[ "protected", "function", "replaceClass", "(", "$", "stub", ",", "$", "name", ")", "{", "$", "formGenerator", "=", "$", "this", "->", "formGenerator", ";", "$", "stub", "=", "str_replace", "(", "'{{class}}'", ",", "$", "formGenerator", "->", "getClassInfo", ...
Replace the class name for the given stub. @param string $stub @param string $name @return string
[ "Replace", "the", "class", "name", "for", "the", "given", "stub", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php#L79-L94
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php
FormMakeCommand.replaceNamespace
protected function replaceNamespace(&$stub, $name) { $path = $this->option('path'); $namespace = $this->option('namespace'); if (!$namespace) { $namespace = $this->formGenerator->getClassInfo($name)->namespace; if ($path) { $namespace = str_replace('...
php
protected function replaceNamespace(&$stub, $name) { $path = $this->option('path'); $namespace = $this->option('namespace'); if (!$namespace) { $namespace = $this->formGenerator->getClassInfo($name)->namespace; if ($path) { $namespace = str_replace('...
[ "protected", "function", "replaceNamespace", "(", "&", "$", "stub", ",", "$", "name", ")", "{", "$", "path", "=", "$", "this", "->", "option", "(", "'path'", ")", ";", "$", "namespace", "=", "$", "this", "->", "option", "(", "'namespace'", ")", ";", ...
Replace the namespace for the given stub. @param string $stub @param string $name @return $this
[ "Replace", "the", "namespace", "for", "the", "given", "stub", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php#L103-L124
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php
FormMakeCommand.getAutoload
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', []...
php
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', []...
[ "protected", "function", "getAutoload", "(", ")", "{", "$", "composerPath", "=", "base_path", "(", "'/composer.json'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "composerPath", ")", ")", "{", "return", "[", "]", ";", "}", "$", "composer", "=", ...
Get psr-4 namespace. @return array
[ "Get", "psr", "-", "4", "namespace", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Console/FormMakeCommand.php#L141-L152
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setupValue
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) { ...
php
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) { ...
[ "protected", "function", "setupValue", "(", ")", "{", "$", "value", "=", "$", "this", "->", "getOption", "(", "$", "this", "->", "valueProperty", ")", ";", "$", "isChild", "=", "$", "this", "->", "getOption", "(", "'is_child'", ")", ";", "if", "(", "...
Setup the value of the form field. @return void
[ "Setup", "the", "value", "of", "the", "form", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L135-L149
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.render
public function render(array $options = [], $showLabel = true, $showField = true, $showError = true) { $this->prepareOptions($options); $value = $this->getValue(); $defaultValue = $this->getDefaultValue(); if ($showField) { $this->rendered = true; } // O...
php
public function render(array $options = [], $showLabel = true, $showField = true, $showError = true) { $this->prepareOptions($options); $value = $this->getValue(); $defaultValue = $this->getDefaultValue(); if ($showField) { $this->rendered = true; } // O...
[ "public", "function", "render", "(", "array", "$", "options", "=", "[", "]", ",", "$", "showLabel", "=", "true", ",", "$", "showField", "=", "true", ",", "$", "showError", "=", "true", ")", "{", "$", "this", "->", "prepareOptions", "(", "$", "options...
Render the field. @param array $options @param bool $showLabel @param bool $showField @param bool $showError @return string
[ "Render", "the", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L175-L214
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.getModelValueAttribute
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)) { ...
php
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)) { ...
[ "protected", "function", "getModelValueAttribute", "(", "$", "model", ",", "$", "name", ")", "{", "$", "transformedName", "=", "$", "this", "->", "transformKey", "(", "$", "name", ")", ";", "if", "(", "is_string", "(", "$", "model", ")", ")", "{", "ret...
Get the attribute value from the model by name. @param mixed $model @param string $name @return mixed
[ "Get", "the", "attribute", "value", "from", "the", "model", "by", "name", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L232-L242
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.prepareOptions
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($this-...
php
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($this-...
[ "protected", "function", "prepareOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "helper", "=", "$", "this", "->", "formHelper", ";", "$", "rulesParser", "=", "$", "helper", "->", "createRulesParser", "(", "$", "this", ")", ";", "...
Prepare options for rendering. @param array $options @return array
[ "Prepare", "options", "for", "rendering", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L261-L322
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setOption
public function setOption($name, $value) { Arr::set($this->options, $name, $value); return $this; }
php
public function setOption($name, $value) { Arr::set($this->options, $name, $value); return $this; }
[ "public", "function", "setOption", "(", "$", "name", ",", "$", "value", ")", "{", "Arr", "::", "set", "(", "$", "this", "->", "options", ",", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set single option on the field. @param string $name @param mixed $value @return $this
[ "Set", "single", "option", "on", "the", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L399-L404
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setType
public function setType($type) { if ($this->formHelper->getFieldType($type)) { $this->type = $type; } return $this; }
php
public function setType($type) { if ($this->formHelper->getFieldType($type)) { $this->type = $type; } return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "$", "this", "->", "formHelper", "->", "getFieldType", "(", "$", "type", ")", ")", "{", "$", "this", "->", "type", "=", "$", "type", ";", "}", "return", "$", "this", ";", "}"...
Set type of the field. @param mixed $type @return $this
[ "Set", "type", "of", "the", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L422-L429
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.allDefaults
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->ge...
php
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->ge...
[ "private", "function", "allDefaults", "(", ")", "{", "return", "[", "'wrapper'", "=>", "[", "'class'", "=>", "$", "this", "->", "getConfig", "(", "'defaults.wrapper_class'", ")", "]", ",", "'attr'", "=>", "[", "'class'", "=>", "$", "this", "->", "getConfig...
Defaults used across all fields. @return array
[ "Defaults", "used", "across", "all", "fields", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L464-L482
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.addErrorClass
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 = $this->getConfi...
php
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 = $this->getConfi...
[ "protected", "function", "addErrorClass", "(", ")", "{", "$", "errors", "=", "$", "this", "->", "parent", "->", "getRequest", "(", ")", "->", "session", "(", ")", "->", "get", "(", "'errors'", ")", ";", "$", "errorBag", "=", "$", "this", "->", "paren...
Add error class to wrapper if validation errors exist. @return void
[ "Add", "error", "class", "to", "wrapper", "if", "validation", "errors", "exist", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L534-L556
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setDefaultOptions
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 = $this->formHel...
php
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 = $this->formHel...
[ "protected", "function", "setDefaultOptions", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "options", "=", "$", "this", "->", "formHelper", "->", "mergeOptions", "(", "$", "this", "->", "allDefaults", "(", ")", ",", "$", "t...
Merge all defaults with field specific defaults and set template if passed. @param array $options
[ "Merge", "all", "defaults", "with", "field", "specific", "defaults", "and", "set", "template", "if", "passed", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L563-L572
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setDefaultClasses
protected function setDefaultClasses(array $options = []) { $wrapper_class = $this->getConfig('defaults.' . $this->type . '.wrapper_class', ''); $label_class = $this->getConfig('defaults.' . $this->type . '.label_class', ''); $field_class = $this->getConfig('defaults.' . $this->type . '.fiel...
php
protected function setDefaultClasses(array $options = []) { $wrapper_class = $this->getConfig('defaults.' . $this->type . '.wrapper_class', ''); $label_class = $this->getConfig('defaults.' . $this->type . '.label_class', ''); $field_class = $this->getConfig('defaults.' . $this->type . '.fiel...
[ "protected", "function", "setDefaultClasses", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "wrapper_class", "=", "$", "this", "->", "getConfig", "(", "'defaults.'", ".", "$", "this", "->", "type", ".", "'.wrapper_class'", ",", "''", ")", "...
Creates default wrapper classes for the form element. @param array $options @return array
[ "Creates", "default", "wrapper", "classes", "for", "the", "form", "element", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L580-L597
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setupLabel
protected function setupLabel() { if ($this->getOption('label') !== null) { return; } if ($template = $this->parent->getTranslationTemplate()) { $label = str_replace( ['{name}', '{type}'], [$this->getRealName(), 'label'], ...
php
protected function setupLabel() { if ($this->getOption('label') !== null) { return; } if ($template = $this->parent->getTranslationTemplate()) { $label = str_replace( ['{name}', '{type}'], [$this->getRealName(), 'label'], ...
[ "protected", "function", "setupLabel", "(", ")", "{", "if", "(", "$", "this", "->", "getOption", "(", "'label'", ")", "!==", "null", ")", "{", "return", ";", "}", "if", "(", "$", "template", "=", "$", "this", "->", "parent", "->", "getTranslationTempla...
Setup the label for the form field. @return void
[ "Setup", "the", "label", "for", "the", "form", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L604-L623
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.needsLabel
protected function needsLabel() { // If field is <select> and child of choice, we don't need label for it $isChildSelect = $this->type == 'select' && $this->getOption('is_child') === true; if ($this->type == 'hidden' || $isChildSelect) { return false; } return t...
php
protected function needsLabel() { // If field is <select> and child of choice, we don't need label for it $isChildSelect = $this->type == 'select' && $this->getOption('is_child') === true; if ($this->type == 'hidden' || $isChildSelect) { return false; } return t...
[ "protected", "function", "needsLabel", "(", ")", "{", "// If field is <select> and child of choice, we don't need label for it", "$", "isChildSelect", "=", "$", "this", "->", "type", "==", "'select'", "&&", "$", "this", "->", "getOption", "(", "'is_child'", ")", "==="...
Check if fields needs label. @return bool
[ "Check", "if", "fields", "needs", "label", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L630-L640
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.getValidationRules
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) { ...
php
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) { ...
[ "public", "function", "getValidationRules", "(", ")", "{", "$", "rules", "=", "$", "this", "->", "getOption", "(", "'rules'", ",", "[", "]", ")", ";", "$", "name", "=", "$", "this", "->", "getNameKey", "(", ")", ";", "$", "messages", "=", "$", "thi...
Get validation rules for a field if any with label for attributes. @return array|null
[ "Get", "validation", "rules", "for", "a", "field", "if", "any", "with", "label", "for", "attributes", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L671-L706
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.initFilters
protected function initFilters() { // If override status is set in field options to true // we will change filtersOverride property value to true // so we can override existing filters with registered // alias/name in addFilter method. $overrideStatus = $this->getOption('filt...
php
protected function initFilters() { // If override status is set in field options to true // we will change filtersOverride property value to true // so we can override existing filters with registered // alias/name in addFilter method. $overrideStatus = $this->getOption('filt...
[ "protected", "function", "initFilters", "(", ")", "{", "// If override status is set in field options to true", "// we will change filtersOverride property value to true", "// so we can override existing filters with registered", "// alias/name in addFilter method.", "$", "overrideStatus", "...
Method initFilters used to initialize filters from field options and bind it to the same. @return $this
[ "Method", "initFilters", "used", "to", "initialize", "filters", "from", "field", "options", "and", "bind", "it", "to", "the", "same", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L756-L774
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.setFilters
public function setFilters(array $filters) { $this->clearFilters(); foreach ($filters as $filter) { $this->addFilter($filter); } return $this; }
php
public function setFilters(array $filters) { $this->clearFilters(); foreach ($filters as $filter) { $this->addFilter($filter); } return $this; }
[ "public", "function", "setFilters", "(", "array", "$", "filters", ")", "{", "$", "this", "->", "clearFilters", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "$", "this", "->", "addFilter", "(", "$", "filter", ")", ";",...
Method setFilters used to set filters to current filters property. @param array $filters @return \Kris\LaravelFormBuilder\Fields\FormField
[ "Method", "setFilters", "used", "to", "set", "filters", "to", "current", "filters", "property", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L783-L791
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.addFilter
public function addFilter($filter) { // Resolve filter object from string/object or throw Ex. $filterObj = FilterResolver::instance($filter); // If filtersOverride is allowed we will override filter // with same alias/name if there is one with new resolved filter. if ($this-...
php
public function addFilter($filter) { // Resolve filter object from string/object or throw Ex. $filterObj = FilterResolver::instance($filter); // If filtersOverride is allowed we will override filter // with same alias/name if there is one with new resolved filter. if ($this-...
[ "public", "function", "addFilter", "(", "$", "filter", ")", "{", "// Resolve filter object from string/object or throw Ex.", "$", "filterObj", "=", "FilterResolver", "::", "instance", "(", "$", "filter", ")", ";", "// If filtersOverride is allowed we will override filter", ...
@param string|FilterInterface $filter @return \Kris\LaravelFormBuilder\Fields\FormField @throws FilterAlreadyBindedException
[ "@param", "string|FilterInterface", "$filter" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L811-L838
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.removeFilter
public function removeFilter($name) { $filters = $this->getFilters(); if (array_key_exists($name, $filters)) { unset($filters[$name]); $this->filters = $filters; } return $this; }
php
public function removeFilter($name) { $filters = $this->getFilters(); if (array_key_exists($name, $filters)) { unset($filters[$name]); $this->filters = $filters; } return $this; }
[ "public", "function", "removeFilter", "(", "$", "name", ")", "{", "$", "filters", "=", "$", "this", "->", "getFilters", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "filters", ")", ")", "{", "unset", "(", "$", "filters", ...
Method removeFilter used to remove filter by provided alias/name. @param string $name @return \Kris\LaravelFormBuilder\Fields\FormField
[ "Method", "removeFilter", "used", "to", "remove", "filter", "by", "provided", "alias", "/", "name", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L847-L856
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/FormField.php
FormField.removeFilters
public function removeFilters(array $filterNames) { $filters = $this->getFilters(); foreach ($filterNames as $filterName) { if (array_key_exists($filterName, $filters)) { unset($filters[$filterName]); $this->filters = $filters; } } ...
php
public function removeFilters(array $filterNames) { $filters = $this->getFilters(); foreach ($filterNames as $filterName) { if (array_key_exists($filterName, $filters)) { unset($filters[$filterName]); $this->filters = $filters; } } ...
[ "public", "function", "removeFilters", "(", "array", "$", "filterNames", ")", "{", "$", "filters", "=", "$", "this", "->", "getFilters", "(", ")", ";", "foreach", "(", "$", "filterNames", "as", "$", "filterName", ")", "{", "if", "(", "array_key_exists", ...
Method removeFilters used to remove filters by provided aliases/names. @param array $filterNames @return \Kris\LaravelFormBuilder\Fields\FormField
[ "Method", "removeFilters", "used", "to", "remove", "filters", "by", "provided", "aliases", "/", "names", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/FormField.php#L865-L876
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.parse
public function parse($rules) { $attributes = array(); $rules = $rule = $this->getRulesAsArray($rules); foreach ($rules as $rule) { list($rule, $parameters) = $this->parseRule($rule); if ($rule && method_exists($this, $rule)) { $attributes += $this->...
php
public function parse($rules) { $attributes = array(); $rules = $rule = $this->getRulesAsArray($rules); foreach ($rules as $rule) { list($rule, $parameters) = $this->parseRule($rule); if ($rule && method_exists($this, $rule)) { $attributes += $this->...
[ "public", "function", "parse", "(", "$", "rules", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "$", "rules", "=", "$", "rule", "=", "$", "this", "->", "getRulesAsArray", "(", "$", "rules", ")", ";", "foreach", "(", "$", "rules", "as", ...
Parse a rule for an input into an array of attributes. @param string|array $rules @return array
[ "Parse", "a", "rule", "for", "an", "input", "into", "an", "array", "of", "attributes", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L43-L57
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.digits
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.'}', 't...
php
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.'}', 't...
[ "protected", "function", "digits", "(", "$", "param", ")", "{", "$", "digits", "=", "$", "param", "[", "0", "]", ";", "if", "(", "$", "this", "->", "isNumeric", "(", ")", ")", "{", "return", "[", "'min'", "=>", "pow", "(", "10", ",", "$", "digi...
Check that the value is numeric and contains exactly the given digits. digits:3 --> min="100" max="999" digits:3 --> pattern="\d{3,5}" (text) @param $param @return array @see http://laravel.com/docs/5.1/validation#rule-digits
[ "Check", "that", "the", "value", "is", "numeric", "and", "contains", "exactly", "the", "given", "digits", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L211-L226
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.digitsBetween
protected function digitsBetween($param) { list($min, $max) = $param; if ($this->isNumeric()) { return [ 'min' => pow(10, $min - 1), 'max' => pow(10, $max) - 1, ]; } return [ 'pattern' => '\d{'.$min.','.$max.'}', ...
php
protected function digitsBetween($param) { list($min, $max) = $param; if ($this->isNumeric()) { return [ 'min' => pow(10, $min - 1), 'max' => pow(10, $max) - 1, ]; } return [ 'pattern' => '\d{'.$min.','.$max.'}', ...
[ "protected", "function", "digitsBetween", "(", "$", "param", ")", "{", "list", "(", "$", "min", ",", "$", "max", ")", "=", "$", "param", ";", "if", "(", "$", "this", "->", "isNumeric", "(", ")", ")", "{", "return", "[", "'min'", "=>", "pow", "(",...
Check that the value is numeric and contains between min/max digits. digits_between:3,5 --> min="100" max="99999" digits_between:3,5 --> pattern="\d{3,5}" (text) @param $param @return array @see http://laravel.com/docs/5.1/validation#rule-digits-between
[ "Check", "that", "the", "value", "is", "numeric", "and", "contains", "between", "min", "/", "max", "digits", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L239-L254
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.between
protected function between($param) { list ($min, $max) = $param; if ($this->isNumeric()) { return [ 'min' => $min, 'max' => $max, ]; } return [ 'minlength' => $min, 'maxlength' => $max, ]; }
php
protected function between($param) { list ($min, $max) = $param; if ($this->isNumeric()) { return [ 'min' => $min, 'max' => $max, ]; } return [ 'minlength' => $min, 'maxlength' => $max, ]; }
[ "protected", "function", "between", "(", "$", "param", ")", "{", "list", "(", "$", "min", ",", "$", "max", ")", "=", "$", "param", ";", "if", "(", "$", "this", "->", "isNumeric", "(", ")", ")", "{", "return", "[", "'min'", "=>", "$", "min", ","...
For number/range inputs, check if the number is between the values. For strings, check the length of the string. between:3,5 --> min="3" max="5" (number) between:3,5 --> minlength="3" maxlength="5" (text) @param $param @return array @see http://laravel.com/docs/5.1/validation#rule-between
[ "For", "number", "/", "range", "inputs", "check", "if", "the", "number", "is", "between", "the", "values", ".", "For", "strings", "check", "the", "length", "of", "the", "string", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L316-L331
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.size
protected function size($param) { $size = $param[0]; if ($this->isNumeric()) { return [ 'min' => $size, 'max' => $size, 'title' => $this->getTitle('size.numeric', compact('size')), ]; } return [ 'pa...
php
protected function size($param) { $size = $param[0]; if ($this->isNumeric()) { return [ 'min' => $size, 'max' => $size, 'title' => $this->getTitle('size.numeric', compact('size')), ]; } return [ 'pa...
[ "protected", "function", "size", "(", "$", "param", ")", "{", "$", "size", "=", "$", "param", "[", "0", "]", ";", "if", "(", "$", "this", "->", "isNumeric", "(", ")", ")", "{", "return", "[", "'min'", "=>", "$", "size", ",", "'max'", "=>", "$",...
For numbers: Check an exact value. For strings: Check the length of the string. size:5 --> min="5" max="5" (number) size:5 --> pattern=".{5}" (text) @param mixed $param @return array @see http://laravel.com/docs/5.1/validation#rule-size
[ "For", "numbers", ":", "Check", "an", "exact", "value", ".", "For", "strings", ":", "Check", "the", "length", "of", "the", "string", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L345-L361
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.getTitle
protected function getTitle($rule, $params = array()) { $params['attribute'] = $this->field->getOption('label'); return $this->formHelper->getTranslator()->trans('validation.' . $rule, $params); }
php
protected function getTitle($rule, $params = array()) { $params['attribute'] = $this->field->getOption('label'); return $this->formHelper->getTranslator()->trans('validation.' . $rule, $params); }
[ "protected", "function", "getTitle", "(", "$", "rule", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "[", "'attribute'", "]", "=", "$", "this", "->", "field", "->", "getOption", "(", "'label'", ")", ";", "return", "$", "this", ...
Get the title, used for validating a rule. @param string $rule @param array $params @return string
[ "Get", "the", "title", "used", "for", "validating", "a", "rule", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L479-L484
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.getDateAttribute
protected function getDateAttribute($dateStr) { $format = "Y-m-d"; if ($this->isType(['datetime', 'datetime-local'])) { $format .= '\TH:i:s'; } return date($format, strtotime($dateStr)); }
php
protected function getDateAttribute($dateStr) { $format = "Y-m-d"; if ($this->isType(['datetime', 'datetime-local'])) { $format .= '\TH:i:s'; } return date($format, strtotime($dateStr)); }
[ "protected", "function", "getDateAttribute", "(", "$", "dateStr", ")", "{", "$", "format", "=", "\"Y-m-d\"", ";", "if", "(", "$", "this", "->", "isType", "(", "[", "'datetime'", ",", "'datetime-local'", "]", ")", ")", "{", "$", "format", ".=", "'\\TH:i:s...
Format a date to the correct format, based on the current field. @param $dateStr @return bool|string
[ "Format", "a", "date", "to", "the", "correct", "format", "based", "on", "the", "current", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L513-L521
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.parseRule
protected function parseRule($rules) { if (is_array($rules)) { return $this->parseArrayRule($rules); } if(is_string($rules)) { return $this->parseStringRule($rules); } }
php
protected function parseRule($rules) { if (is_array($rules)) { return $this->parseArrayRule($rules); } if(is_string($rules)) { return $this->parseStringRule($rules); } }
[ "protected", "function", "parseRule", "(", "$", "rules", ")", "{", "if", "(", "is_array", "(", "$", "rules", ")", ")", "{", "return", "$", "this", "->", "parseArrayRule", "(", "$", "rules", ")", ";", "}", "if", "(", "is_string", "(", "$", "rules", ...
Extract the rule name and parameters from a rule. @param array|string $rules @return array|null;
[ "Extract", "the", "rule", "name", "and", "parameters", "from", "a", "rule", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L535-L543
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.parseStringRule
protected function parseStringRule($rules) { $parameters = []; // The format for specifying validation rules and parameters follows an // easy {rule}:{parameters} formatting convention. For instance the // rule "Max:3" states that the value may only be three letters. if (strp...
php
protected function parseStringRule($rules) { $parameters = []; // The format for specifying validation rules and parameters follows an // easy {rule}:{parameters} formatting convention. For instance the // rule "Max:3" states that the value may only be three letters. if (strp...
[ "protected", "function", "parseStringRule", "(", "$", "rules", ")", "{", "$", "parameters", "=", "[", "]", ";", "// The format for specifying validation rules and parameters follows an", "// easy {rule}:{parameters} formatting convention. For instance the", "// rule \"Max:3\" states ...
Parse a string based rule. @param string $rules @return array
[ "Parse", "a", "string", "based", "rule", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L562-L573
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/RulesParser.php
RulesParser.getRulesAsArray
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; }, $...
php
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; }, $...
[ "protected", "function", "getRulesAsArray", "(", "$", "rules", ")", "{", "$", "rulesArray", "=", "(", "is_string", "(", "$", "rules", ")", ")", "?", "explode", "(", "'|'", ",", "$", "rules", ")", ":", "$", "rules", ";", "return", "array_map", "(", "f...
Parse field rules as array and initialize closure rules @param string|array $rules @return array
[ "Parse", "field", "rules", "as", "array", "and", "initialize", "closure", "rules" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/RulesParser.php#L596-L606
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/Uppercase.php
Uppercase.setEncoding
public function setEncoding($encoding) { if ($encoding !== null) { if (!function_exists('mb_strtoupper')) { $ex = new \Exception('mbstring extension is required for value mutating.'); throw $ex; } $encoding = (string) $encoding; ...
php
public function setEncoding($encoding) { if ($encoding !== null) { if (!function_exists('mb_strtoupper')) { $ex = new \Exception('mbstring extension is required for value mutating.'); throw $ex; } $encoding = (string) $encoding; ...
[ "public", "function", "setEncoding", "(", "$", "encoding", ")", "{", "if", "(", "$", "encoding", "!==", "null", ")", "{", "if", "(", "!", "function_exists", "(", "'mb_strtoupper'", ")", ")", "{", "$", "ex", "=", "new", "\\", "Exception", "(", "'mbstrin...
@param null $encoding @return \Kris\LaravelFormBuilder\Filters\Collection\Uppercase @throws \Exception
[ "@param", "null", "$encoding" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/Uppercase.php#L43-L60
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/Uppercase.php
Uppercase.filter
public function filter($value, $options = []) { $value = (string) $value; if ($this->getEncoding()) { return mb_strtoupper($value, $this->getEncoding()); } return strtoupper($value); }
php
public function filter($value, $options = []) { $value = (string) $value; if ($this->getEncoding()) { return mb_strtoupper($value, $this->getEncoding()); } return strtoupper($value); }
[ "public", "function", "filter", "(", "$", "value", ",", "$", "options", "=", "[", "]", ")", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", "if", "(", "$", "this", "->", "getEncoding", "(", ")", ")", "{", "return", "mb_strtoupper", ...
@param mixed $value @param array $options @return string
[ "@param", "mixed", "$value", "@param", "array", "$options" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/Uppercase.php#L76-L84
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/FilterResolver.php
FilterResolver.instance
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::resolveFromCollecti...
php
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::resolveFromCollecti...
[ "public", "static", "function", "instance", "(", "$", "filter", ")", "{", "if", "(", "!", "is_string", "(", "$", "filter", ")", ")", "{", "return", "self", "::", "validateFilterInstance", "(", "$", "filter", ")", ";", "}", "if", "(", "class_exists", "(...
Method instance used to resolve filter parameter to FilterInterface object from filter Alias or object itself. @param mixed $filter @return FilterInterface @throws Exception\UnableToResolveFilterException @throws Exception\InvalidInstanceException
[ "Method", "instance", "used", "to", "resolve", "filter", "parameter", "to", "FilterInterface", "object", "from", "filter", "Alias", "or", "object", "itself", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/FilterResolver.php#L27-L43
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/ChoiceType.php
ChoiceType.determineChoiceField
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...
php
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...
[ "protected", "function", "determineChoiceField", "(", ")", "{", "$", "expanded", "=", "$", "this", "->", "options", "[", "'expanded'", "]", ";", "$", "multiple", "=", "$", "this", "->", "options", "[", "'multiple'", "]", ";", "if", "(", "$", "multiple", ...
Determine which choice type to use. @return string
[ "Determine", "which", "choice", "type", "to", "use", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/ChoiceType.php#L30-L46
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/ChoiceType.php
ChoiceType.createChildren
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->determineChoiceFie...
php
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->determineChoiceFie...
[ "protected", "function", "createChildren", "(", ")", "{", "if", "(", "(", "$", "data_override", "=", "$", "this", "->", "getOption", "(", "'data_override'", ")", ")", "&&", "$", "data_override", "instanceof", "\\", "Closure", ")", "{", "$", "this", "->", ...
Create children depending on choice type. @return void
[ "Create", "children", "depending", "on", "choice", "type", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/ChoiceType.php#L70-L90
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/ChoiceType.php
ChoiceType.buildSelect
protected function buildSelect($fieldType) { $this->children[] = new $fieldType( $this->name, $this->choiceType, $this->parent, $this->formHelper->mergeOptions($this->options, ['is_child' => true]) ); }
php
protected function buildSelect($fieldType) { $this->children[] = new $fieldType( $this->name, $this->choiceType, $this->parent, $this->formHelper->mergeOptions($this->options, ['is_child' => true]) ); }
[ "protected", "function", "buildSelect", "(", "$", "fieldType", ")", "{", "$", "this", "->", "children", "[", "]", "=", "new", "$", "fieldType", "(", "$", "this", "->", "name", ",", "$", "this", "->", "choiceType", ",", "$", "this", "->", "parent", ",...
Build select field from choice. @param string $fieldType
[ "Build", "select", "field", "from", "choice", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/ChoiceType.php#L129-L137
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/ChoiceType.php
ChoiceType.setDefaultClasses
protected function setDefaultClasses(array $options = []) { $defaults = parent::setDefaultClasses($options); $choice_type = $this->determineChoiceField(); $wrapper_class = $this->formHelper->getConfig('defaults.' . $this->type . '.' . $choice_type . '_wrapper_class', ''); if ($wrapp...
php
protected function setDefaultClasses(array $options = []) { $defaults = parent::setDefaultClasses($options); $choice_type = $this->determineChoiceField(); $wrapper_class = $this->formHelper->getConfig('defaults.' . $this->type . '.' . $choice_type . '_wrapper_class', ''); if ($wrapp...
[ "protected", "function", "setDefaultClasses", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "parent", "::", "setDefaultClasses", "(", "$", "options", ")", ";", "$", "choice_type", "=", "$", "this", "->", "determineChoiceField",...
Creates default wrapper classes for the form element. @param array $options @return array
[ "Creates", "default", "wrapper", "classes", "for", "the", "form", "element", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/ChoiceType.php#L145-L170
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Fields/ChildFormType.php
ChildFormType.alterValid
public function alterValid(Form $mainForm, &$isValid) { $this->parent->getFormHelper()->alterValid($this->form, $mainForm, $isValid); }
php
public function alterValid(Form $mainForm, &$isValid) { $this->parent->getFormHelper()->alterValid($this->form, $mainForm, $isValid); }
[ "public", "function", "alterValid", "(", "Form", "$", "mainForm", ",", "&", "$", "isValid", ")", "{", "$", "this", "->", "parent", "->", "getFormHelper", "(", ")", "->", "alterValid", "(", "$", "this", "->", "form", ",", "$", "mainForm", ",", "$", "i...
Allow form-specific valid alters. @param Form $mainForm @param bool $isValid @return void
[ "Allow", "form", "-", "specific", "valid", "alters", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Fields/ChildFormType.php#L72-L75
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Console/FormGenerator.php
FormGenerator.parseFields
protected function parseFields($fields) { $fieldsArray = explode(',', $fields); $text = '$this'."\n"; foreach ($fieldsArray as $field) { $text .= $this->prepareAdd($field, end($fieldsArray) == $field); } return $text.';'; }
php
protected function parseFields($fields) { $fieldsArray = explode(',', $fields); $text = '$this'."\n"; foreach ($fieldsArray as $field) { $text .= $this->prepareAdd($field, end($fieldsArray) == $field); } return $text.';'; }
[ "protected", "function", "parseFields", "(", "$", "fields", ")", "{", "$", "fieldsArray", "=", "explode", "(", "','", ",", "$", "fields", ")", ";", "$", "text", "=", "'$this'", ".", "\"\\n\"", ";", "foreach", "(", "$", "fieldsArray", "as", "$", "field"...
Parse fields from string. @param string $fields @return string
[ "Parse", "fields", "from", "string", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Console/FormGenerator.php#L45-L55
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Console/FormGenerator.php
FormGenerator.prepareAdd
protected function prepareAdd($field, $isLast = false) { $field = trim($field); list($name, $type) = explode(':', $field); $textArr = [ " ->add('", $name, "', '", $type, "')", ($isLast) ? "" : "\n" ]; ...
php
protected function prepareAdd($field, $isLast = false) { $field = trim($field); list($name, $type) = explode(':', $field); $textArr = [ " ->add('", $name, "', '", $type, "')", ($isLast) ? "" : "\n" ]; ...
[ "protected", "function", "prepareAdd", "(", "$", "field", ",", "$", "isLast", "=", "false", ")", "{", "$", "field", "=", "trim", "(", "$", "field", ")", ";", "list", "(", "$", "name", ",", "$", "type", ")", "=", "explode", "(", "':'", ",", "$", ...
Prepare template for single add field. @param string $field @param bool $isLast @return string
[ "Prepare", "template", "for", "single", "add", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Console/FormGenerator.php#L64-L78
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php
XSS.filter
public function filter($value, $options = []) { do { // Treat $input as buffer on each loop, faster // than new var && Remove unwanted tags $input = $value; $output = $this->stripTags($input); $output = $this->stripEncodedEntities($output); ...
php
public function filter($value, $options = []) { do { // Treat $input as buffer on each loop, faster // than new var && Remove unwanted tags $input = $value; $output = $this->stripTags($input); $output = $this->stripEncodedEntities($output); ...
[ "public", "function", "filter", "(", "$", "value", ",", "$", "options", "=", "[", "]", ")", "{", "do", "{", "// Treat $input as buffer on each loop, faster", "// than new var && Remove unwanted tags", "$", "input", "=", "$", "value", ";", "$", "output", "=", "$"...
@param mixed $value @param array $options @return mixed
[ "@param", "mixed", "$value", "@param", "array", "$options" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php#L33-L50
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php
XSS.stripEncodedEntities
private function stripEncodedEntities($input) { // Fix &entity\n; $input = str_replace(array('&amp;','&lt;','&gt;'), array('&amp;amp;','&amp;lt;','&amp;gt;'), $input); $input = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $input); $input = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1...
php
private function stripEncodedEntities($input) { // Fix &entity\n; $input = str_replace(array('&amp;','&lt;','&gt;'), array('&amp;amp;','&amp;lt;','&amp;gt;'), $input); $input = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $input); $input = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1...
[ "private", "function", "stripEncodedEntities", "(", "$", "input", ")", "{", "// Fix &entity\\n;", "$", "input", "=", "str_replace", "(", "array", "(", "'&amp;'", ",", "'&lt;'", ",", "'&gt;'", ")", ",", "array", "(", "'&amp;amp;'", ",", "'&amp;lt;'", ",", "'&...
Focuses on stripping encoded entities *** This appears to be why people use this sample code. Unclear how well Kses does this *** @param string $input Content to be cleaned. It MAY be modified in output @return string $input Modified $input string @author Mike Bijon <https://github.com/mbijon>
[ "Focuses", "on", "stripping", "encoded", "entities", "***", "This", "appears", "to", "be", "why", "people", "use", "this", "sample", "code", ".", "Unclear", "how", "well", "Kses", "does", "this", "***" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php#L62-L84
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php
XSS.stripBase64
private function stripBase64($input) { $decoded = base64_decode($input); $decoded = $this->stripTags($decoded); $decoded = $this->stripEncodedEntities($decoded); $output = base64_encode($decoded); return $output; }
php
private function stripBase64($input) { $decoded = base64_decode($input); $decoded = $this->stripTags($decoded); $decoded = $this->stripEncodedEntities($decoded); $output = base64_encode($decoded); return $output; }
[ "private", "function", "stripBase64", "(", "$", "input", ")", "{", "$", "decoded", "=", "base64_decode", "(", "$", "input", ")", ";", "$", "decoded", "=", "$", "this", "->", "stripTags", "(", "$", "decoded", ")", ";", "$", "decoded", "=", "$", "this"...
Focuses on stripping entities from Base64 encoded strings NOT ENABLED by default! To enable 2nd param of clean_input() can be set to anything other than 0 or '0': ie: xssClean->clean_input( $input_string, 1 ) @param string $input Maybe Base64 encoded string @return string $output Modified & re-encoded ...
[ "Focuses", "on", "stripping", "entities", "from", "Base64", "encoded", "strings" ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/Filters/Collection/XSS.php#L119-L127
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.prepareAttributes
public function prepareAttributes($options) { if (!$options) { return null; } $attributes = []; foreach ($options as $name => $option) { if ($option !== null) { $name = is_numeric($name) ? $option : $name; $attributes[] = $nam...
php
public function prepareAttributes($options) { if (!$options) { return null; } $attributes = []; foreach ($options as $name => $option) { if ($option !== null) { $name = is_numeric($name) ? $option : $name; $attributes[] = $nam...
[ "public", "function", "prepareAttributes", "(", "$", "options", ")", "{", "if", "(", "!", "$", "options", ")", "{", "return", "null", ";", "}", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "options", "as", "$", "name", "=>", "$", "op...
Convert array of attributes to html attributes. @param $options @return string
[ "Convert", "array", "of", "attributes", "to", "html", "attributes", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L181-L197
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.addCustomField
public function addCustomField($name, $class) { if (!$this->hasCustomField($name)) { return $this->customTypes[$name] = $class; } throw new \InvalidArgumentException('Custom field ['.$name.'] already exists on this form object.'); }
php
public function addCustomField($name, $class) { if (!$this->hasCustomField($name)) { return $this->customTypes[$name] = $class; } throw new \InvalidArgumentException('Custom field ['.$name.'] already exists on this form object.'); }
[ "public", "function", "addCustomField", "(", "$", "name", ",", "$", "class", ")", "{", "if", "(", "!", "$", "this", "->", "hasCustomField", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "customTypes", "[", "$", "name", "]", "=", "$"...
Add custom field. @param $name @param $class
[ "Add", "custom", "field", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L205-L212
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.loadCustomTypes
private function loadCustomTypes() { $customFields = (array) $this->getConfig('custom_fields'); if (!empty($customFields)) { foreach ($customFields as $fieldName => $fieldClass) { $this->addCustomField($fieldName, $fieldClass); } } }
php
private function loadCustomTypes() { $customFields = (array) $this->getConfig('custom_fields'); if (!empty($customFields)) { foreach ($customFields as $fieldName => $fieldClass) { $this->addCustomField($fieldName, $fieldClass); } } }
[ "private", "function", "loadCustomTypes", "(", ")", "{", "$", "customFields", "=", "(", "array", ")", "$", "this", "->", "getConfig", "(", "'custom_fields'", ")", ";", "if", "(", "!", "empty", "(", "$", "customFields", ")", ")", "{", "foreach", "(", "$...
Load custom field types from config file.
[ "Load", "custom", "field", "types", "from", "config", "file", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L217-L226
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.formatLabel
public function formatLabel($name) { if (!$name) { return null; } if ($this->translator->has($name)) { $translatedName = $this->translator->get($name); if (is_string($translatedName)) { return $translatedName; } } ...
php
public function formatLabel($name) { if (!$name) { return null; } if ($this->translator->has($name)) { $translatedName = $this->translator->get($name); if (is_string($translatedName)) { return $translatedName; } } ...
[ "public", "function", "formatLabel", "(", "$", "name", ")", "{", "if", "(", "!", "$", "name", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "translator", "->", "has", "(", "$", "name", ")", ")", "{", "$", "translatedName", "...
Format the label to the proper format. @param $name @return string
[ "Format", "the", "label", "to", "the", "proper", "format", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L265-L280
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.alterFieldValues
public function alterFieldValues(Form $form, array &$values) { // Alter the form itself $form->alterFieldValues($values); // Alter the form's child forms recursively foreach ($form->getFields() as $name => $field) { if (method_exists($field, 'alterFieldValues')) { ...
php
public function alterFieldValues(Form $form, array &$values) { // Alter the form itself $form->alterFieldValues($values); // Alter the form's child forms recursively foreach ($form->getFields() as $name => $field) { if (method_exists($field, 'alterFieldValues')) { ...
[ "public", "function", "alterFieldValues", "(", "Form", "$", "form", ",", "array", "&", "$", "values", ")", "{", "// Alter the form itself", "$", "form", "->", "alterFieldValues", "(", "$", "values", ")", ";", "// Alter the form's child forms recursively", "foreach",...
Alter a form's values recursively according to its fields. @param Form $form @param array $values @return void
[ "Alter", "a", "form", "s", "values", "recursively", "according", "to", "its", "fields", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L345-L360
kristijanhusak/laravel-form-builder
src/Kris/LaravelFormBuilder/FormHelper.php
FormHelper.alterValid
public function alterValid(Form $form, Form $mainForm, &$isValid) { // Alter the form itself $messages = $form->alterValid($mainForm, $isValid); // Add messages to the existing Bag if ($messages) { $messageBag = $mainForm->getValidator()->getMessageBag(); $th...
php
public function alterValid(Form $form, Form $mainForm, &$isValid) { // Alter the form itself $messages = $form->alterValid($mainForm, $isValid); // Add messages to the existing Bag if ($messages) { $messageBag = $mainForm->getValidator()->getMessageBag(); $th...
[ "public", "function", "alterValid", "(", "Form", "$", "form", ",", "Form", "$", "mainForm", ",", "&", "$", "isValid", ")", "{", "// Alter the form itself", "$", "messages", "=", "$", "form", "->", "alterValid", "(", "$", "mainForm", ",", "$", "isValid", ...
Alter a form's validity recursively, and add messages with nested form prefix. @return void
[ "Alter", "a", "form", "s", "validity", "recursively", "and", "add", "messages", "with", "nested", "form", "prefix", "." ]
train
https://github.com/kristijanhusak/laravel-form-builder/blob/06a1202861e612d088306f6a329d6f01b0f51d71/src/Kris/LaravelFormBuilder/FormHelper.php#L367-L384