id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,600 | tylercd100/lern | src/Components/Recorder.php | Recorder.excludeKeys | protected function excludeKeys(array $data) {
$keys = isset($this->config['excludeKeys']) ? $this->config['excludeKeys'] : [];
foreach ($data as $key => &$value) {
if (in_array($key, $keys)) {
unset($data[$key]);
} else if (is_array($value)) {
... | php | protected function excludeKeys(array $data) {
$keys = isset($this->config['excludeKeys']) ? $this->config['excludeKeys'] : [];
foreach ($data as $key => &$value) {
if (in_array($key, $keys)) {
unset($data[$key]);
} else if (is_array($value)) {
... | [
"protected",
"function",
"excludeKeys",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"keys",
"=",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'excludeKeys'",
"]",
")",
"?",
"$",
"this",
"->",
"config",
"[",
"'excludeKeys'",
"]",
":",
"[",
"]",
";",... | This function will remove all keys from an array recursively as defined in the config file
@param array $data The array to remove keys from
@return void | [
"This",
"function",
"will",
"remove",
"all",
"keys",
"from",
"an",
"array",
"recursively",
"as",
"defined",
"in",
"the",
"config",
"file"
] | ab6b602d11447d305770aa8cbb79278428dd2244 | https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Recorder.php#L203-L214 |
30,601 | BKWLD/decoy | classes/Commands/Admin.php | Admin.handle | public function handle()
{
$firstName = $this->ask('First Name');
$lastName = $this->ask('Last Name');
$email = $this->ask('Email');
// Check the email to see if its already being used
if ($admin = BkwldAdmin::where('email', $email)->exists()) {
$this->error('Tha... | php | public function handle()
{
$firstName = $this->ask('First Name');
$lastName = $this->ask('Last Name');
$email = $this->ask('Email');
// Check the email to see if its already being used
if ($admin = BkwldAdmin::where('email', $email)->exists()) {
$this->error('Tha... | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"firstName",
"=",
"$",
"this",
"->",
"ask",
"(",
"'First Name'",
")",
";",
"$",
"lastName",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Last Name'",
")",
";",
"$",
"email",
"=",
"$",
"this",
"->",
"ask"... | Create the new admin with input from the user
@return void | [
"Create",
"the",
"new",
"admin",
"with",
"input",
"from",
"the",
"user"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Commands/Admin.php#L29-L62 |
30,602 | BKWLD/decoy | classes/Models/RedirectRule.php | RedirectRule.onValidating | public function onValidating($validation)
{
// Clean up "from" route, stripping host and leading slash
$this->from = preg_replace('#^([^/]*//[^/]+)?/?#', '', $this->from);
// Make an absolute path if the current domain is entered
$this->to = Utils\URL::urlToAbsolutePath($this->to);
... | php | public function onValidating($validation)
{
// Clean up "from" route, stripping host and leading slash
$this->from = preg_replace('#^([^/]*//[^/]+)?/?#', '', $this->from);
// Make an absolute path if the current domain is entered
$this->to = Utils\URL::urlToAbsolutePath($this->to);
... | [
"public",
"function",
"onValidating",
"(",
"$",
"validation",
")",
"{",
"// Clean up \"from\" route, stripping host and leading slash",
"$",
"this",
"->",
"from",
"=",
"preg_replace",
"(",
"'#^([^/]*//[^/]+)?/?#'",
",",
"''",
",",
"$",
"this",
"->",
"from",
")",
";"... | Pre-validation rules
@param Illuminate\Validation\Validator $validation
@return null | [
"Pre",
"-",
"validation",
"rules"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/RedirectRule.php#L72-L86 |
30,603 | BKWLD/decoy | classes/Models/RedirectRule.php | RedirectRule.scopeMatchUsingRequest | public function scopeMatchUsingRequest($query)
{
return $query->where(function ($query) {
$from = $this->pathAndQuery();
$escaped_from = DB::connection()->getPdo()->quote($from);
$from_col = DB::getDriverName() == 'sqlsrv' ? '[from]' : '`from`';
$query->where(... | php | public function scopeMatchUsingRequest($query)
{
return $query->where(function ($query) {
$from = $this->pathAndQuery();
$escaped_from = DB::connection()->getPdo()->quote($from);
$from_col = DB::getDriverName() == 'sqlsrv' ? '[from]' : '`from`';
$query->where(... | [
"public",
"function",
"scopeMatchUsingRequest",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"from",
"=",
"$",
"this",
"->",
"pathAndQuery",
"(",
")",
";",
"$",
"escaped_from",
"... | See if the current request matches the "FROM" using progressively more
expensive ways to match the from column.
@param Illuminate\Database\Query\Builder $query
@return void | [
"See",
"if",
"the",
"current",
"request",
"matches",
"the",
"FROM",
"using",
"progressively",
"more",
"expensive",
"ways",
"to",
"match",
"the",
"from",
"column",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/RedirectRule.php#L107-L118 |
30,604 | BKWLD/decoy | classes/Models/RedirectRule.php | RedirectRule.pathAndQuery | public function pathAndQuery()
{
$query = Request::getQueryString();
$path = ltrim(Request::path(), '/'); // ltrim fixes homepage
return $query ? $path.'?'.$query : $path;
} | php | public function pathAndQuery()
{
$query = Request::getQueryString();
$path = ltrim(Request::path(), '/'); // ltrim fixes homepage
return $query ? $path.'?'.$query : $path;
} | [
"public",
"function",
"pathAndQuery",
"(",
")",
"{",
"$",
"query",
"=",
"Request",
"::",
"getQueryString",
"(",
")",
";",
"$",
"path",
"=",
"ltrim",
"(",
"Request",
"::",
"path",
"(",
")",
",",
"'/'",
")",
";",
"// ltrim fixes homepage",
"return",
"$",
... | Get the path and query from the request
@return string | [
"Get",
"the",
"path",
"and",
"query",
"from",
"the",
"request"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/RedirectRule.php#L125-L130 |
30,605 | BKWLD/decoy | classes/Fields/Listing.php | Listing.createFromController | public static function createFromController($controller, $items)
{
$model = $controller->model();
return Former::listing($model, null, null, null, [
'controller' => $controller,
'items' => $items,
]);
} | php | public static function createFromController($controller, $items)
{
$model = $controller->model();
return Former::listing($model, null, null, null, [
'controller' => $controller,
'items' => $items,
]);
} | [
"public",
"static",
"function",
"createFromController",
"(",
"$",
"controller",
",",
"$",
"items",
")",
"{",
"$",
"model",
"=",
"$",
"controller",
"->",
"model",
"(",
")",
";",
"return",
"Former",
"::",
"listing",
"(",
"$",
"model",
",",
"null",
",",
"... | A factory to create an instance using the passed controller. This is to prevent
duplicate controller instantations when invoked from the base controller.
@param Bkwld\Decoy\Controllers\Base $controller
@param LengthAwarePaginator $items
@return Bkwld\Decoy\Field\Listing | [
"A",
"factory",
"to",
"create",
"an",
"instance",
"using",
"the",
"passed",
"controller",
".",
"This",
"is",
"to",
"prevent",
"duplicate",
"controller",
"instantations",
"when",
"invoked",
"from",
"the",
"base",
"controller",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L136-L144 |
30,606 | BKWLD/decoy | classes/Fields/Listing.php | Listing.controller | public function controller($controller)
{
// Instantiate a string controller
if (is_string($controller)
&& class_exists($controller)
&& is_subclass_of($controller, 'Bkwld\Decoy\Controllers\Base')) {
$this->controller_name = $controller;
$this->control... | php | public function controller($controller)
{
// Instantiate a string controller
if (is_string($controller)
&& class_exists($controller)
&& is_subclass_of($controller, 'Bkwld\Decoy\Controllers\Base')) {
$this->controller_name = $controller;
$this->control... | [
"public",
"function",
"controller",
"(",
"$",
"controller",
")",
"{",
"// Instantiate a string controller",
"if",
"(",
"is_string",
"(",
"$",
"controller",
")",
"&&",
"class_exists",
"(",
"$",
"controller",
")",
"&&",
"is_subclass_of",
"(",
"$",
"controller",
",... | Replace the controller
@param Bkwld\Decoy\Controllers\Base | string $controller
@return Field This field | [
"Replace",
"the",
"controller"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L152-L176 |
30,607 | BKWLD/decoy | classes/Fields/Listing.php | Listing.wrapAndRender | public function wrapAndRender()
{
// Don't set an id
$this->setAttribute('id', false);
// Because it's a field, Former will add this. But it's not really
// appropriate for a listing
$this->removeClass('form-control');
// Render the markup
if ($this->layout... | php | public function wrapAndRender()
{
// Don't set an id
$this->setAttribute('id', false);
// Because it's a field, Former will add this. But it's not really
// appropriate for a listing
$this->removeClass('form-control');
// Render the markup
if ($this->layout... | [
"public",
"function",
"wrapAndRender",
"(",
")",
"{",
"// Don't set an id",
"$",
"this",
"->",
"setAttribute",
"(",
"'id'",
",",
"false",
")",
";",
"// Because it's a field, Former will add this. But it's not really",
"// appropriate for a listing",
"$",
"this",
"->",
"r... | Render the layout, .i.e. put it in a control group or a different
wrapper
@return string HTML | [
"Render",
"the",
"layout",
".",
"i",
".",
"e",
".",
"put",
"it",
"in",
"a",
"control",
"group",
"or",
"a",
"different",
"wrapper"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L254-L269 |
30,608 | BKWLD/decoy | classes/Fields/Listing.php | Listing.wrapInControlGroup | protected function wrapInControlGroup()
{
// Add generic stuff
$this->addGroupClass('list-form-group');
// Use the controller description for blockhelp
if (!$this->hasHelp()) {
$this->blockhelp($this->controller->description());
}
// Show no results if t... | php | protected function wrapInControlGroup()
{
// Add generic stuff
$this->addGroupClass('list-form-group');
// Use the controller description for blockhelp
if (!$this->hasHelp()) {
$this->blockhelp($this->controller->description());
}
// Show no results if t... | [
"protected",
"function",
"wrapInControlGroup",
"(",
")",
"{",
"// Add generic stuff",
"$",
"this",
"->",
"addGroupClass",
"(",
"'list-form-group'",
")",
";",
"// Use the controller description for blockhelp",
"if",
"(",
"!",
"$",
"this",
"->",
"hasHelp",
"(",
")",
"... | Add customization to the control group rendering
@return string HTML | [
"Add",
"customization",
"to",
"the",
"control",
"group",
"rendering"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L276-L305 |
30,609 | BKWLD/decoy | classes/Fields/Listing.php | Listing.getIndexURL | protected function getIndexURL()
{
return $this->controller->isChildInManyToMany() ?
DecoyURL::action($this->controller_name.'@index') :
DecoyURL::relative('index', null, $this->controller_name);
} | php | protected function getIndexURL()
{
return $this->controller->isChildInManyToMany() ?
DecoyURL::action($this->controller_name.'@index') :
DecoyURL::relative('index', null, $this->controller_name);
} | [
"protected",
"function",
"getIndexURL",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"isChildInManyToMany",
"(",
")",
"?",
"DecoyURL",
"::",
"action",
"(",
"$",
"this",
"->",
"controller_name",
".",
"'@index'",
")",
":",
"DecoyURL",
"::",
... | Get the index URL for this controller
@return string URL | [
"Get",
"the",
"index",
"URL",
"for",
"this",
"controller"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L383-L388 |
30,610 | BKWLD/decoy | classes/Fields/Listing.php | Listing.getColumns | protected function getColumns($controller)
{
// If user has defined columns, use them
if ($this->columns) {
return $this->columns;
}
// Read columns from the controller
$columns = $controller->columns();
// If showing in sidebar, only show the first colu... | php | protected function getColumns($controller)
{
// If user has defined columns, use them
if ($this->columns) {
return $this->columns;
}
// Read columns from the controller
$columns = $controller->columns();
// If showing in sidebar, only show the first colu... | [
"protected",
"function",
"getColumns",
"(",
"$",
"controller",
")",
"{",
"// If user has defined columns, use them",
"if",
"(",
"$",
"this",
"->",
"columns",
")",
"{",
"return",
"$",
"this",
"->",
"columns",
";",
"}",
"// Read columns from the controller",
"$",
"c... | Get the list of columns of the controller
@param Bkwld\Decoy\Controller\Base $controller A controller instance
@return array Associative array of column keys and values | [
"Get",
"the",
"list",
"of",
"columns",
"of",
"the",
"controller"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L408-L428 |
30,611 | BKWLD/decoy | classes/Fields/Listing.php | Listing.queryForItems | protected function queryForItems()
{
// If there is a parent, run the query through the relationship to this model
// from the parent
if ($this->parent_item) {
$relationship = Decoy::hasManyName($this->name);
$query = $this->parent_item->$relationship()->ordered();
... | php | protected function queryForItems()
{
// If there is a parent, run the query through the relationship to this model
// from the parent
if ($this->parent_item) {
$relationship = Decoy::hasManyName($this->name);
$query = $this->parent_item->$relationship()->ordered();
... | [
"protected",
"function",
"queryForItems",
"(",
")",
"{",
"// If there is a parent, run the query through the relationship to this model",
"// from the parent",
"if",
"(",
"$",
"this",
"->",
"parent_item",
")",
"{",
"$",
"relationship",
"=",
"Decoy",
"::",
"hasManyName",
"... | Write an execute a query to get the list of items
@return LengthAwarePaginator | [
"Write",
"an",
"execute",
"a",
"query",
"to",
"get",
"the",
"list",
"of",
"items"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L451-L472 |
30,612 | BKWLD/decoy | classes/Fields/Listing.php | Listing.perPage | protected function perPage()
{
// If the user specified a limit, use it
if ($this->take) {
return $this->take;
}
// If a sidebar, use the default
if ($this->layout == 'sidebar') {
$name = $this->controller_name;
return $name::$per_sidebar... | php | protected function perPage()
{
// If the user specified a limit, use it
if ($this->take) {
return $this->take;
}
// If a sidebar, use the default
if ($this->layout == 'sidebar') {
$name = $this->controller_name;
return $name::$per_sidebar... | [
"protected",
"function",
"perPage",
"(",
")",
"{",
"// If the user specified a limit, use it",
"if",
"(",
"$",
"this",
"->",
"take",
")",
"{",
"return",
"$",
"this",
"->",
"take",
";",
"}",
"// If a sidebar, use the default",
"if",
"(",
"$",
"this",
"->",
"lay... | Get the amount per page be looking at a number of different sources
@return int The amount | [
"Get",
"the",
"amount",
"per",
"page",
"be",
"looking",
"at",
"a",
"number",
"of",
"different",
"sources"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Listing.php#L479-L495 |
30,613 | BKWLD/decoy | classes/ServiceProvider.php | ServiceProvider.registerDirectories | public function registerDirectories()
{
// Publish config files
$this->publishes([
__DIR__.'/../config' => config_path('decoy')
], 'config');
// Publish decoy css and js to public directory
$this->publishes([
__DIR__.'/../dist' => public_path('assets... | php | public function registerDirectories()
{
// Publish config files
$this->publishes([
__DIR__.'/../config' => config_path('decoy')
], 'config');
// Publish decoy css and js to public directory
$this->publishes([
__DIR__.'/../dist' => public_path('assets... | [
"public",
"function",
"registerDirectories",
"(",
")",
"{",
"// Publish config files",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../config'",
"=>",
"config_path",
"(",
"'decoy'",
")",
"]",
",",
"'config'",
")",
";",
"// Publish decoy css and js ... | Register configs, migrations, etc
@return void | [
"Register",
"configs",
"migrations",
"etc"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/ServiceProvider.php#L61-L86 |
30,614 | BKWLD/decoy | classes/ServiceProvider.php | ServiceProvider.usingAdmin | public function usingAdmin()
{
// Define constants that Decoy uses
if (!defined('FORMAT_DATE')) {
define('FORMAT_DATE', __('decoy::base.constants.format_date'));
}
if (!defined('FORMAT_DATETIME')) {
define('FORMAT_DATETIME', __('decoy::base.constants.format_d... | php | public function usingAdmin()
{
// Define constants that Decoy uses
if (!defined('FORMAT_DATE')) {
define('FORMAT_DATE', __('decoy::base.constants.format_date'));
}
if (!defined('FORMAT_DATETIME')) {
define('FORMAT_DATETIME', __('decoy::base.constants.format_d... | [
"public",
"function",
"usingAdmin",
"(",
")",
"{",
"// Define constants that Decoy uses",
"if",
"(",
"!",
"defined",
"(",
"'FORMAT_DATE'",
")",
")",
"{",
"define",
"(",
"'FORMAT_DATE'",
",",
"__",
"(",
"'decoy::base.constants.format_date'",
")",
")",
";",
"}",
"... | Things that happen only if the request is for the admin | [
"Things",
"that",
"happen",
"only",
"if",
"the",
"request",
"is",
"for",
"the",
"admin"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/ServiceProvider.php#L91-L130 |
30,615 | BKWLD/decoy | classes/ServiceProvider.php | ServiceProvider.bootAuth | public function bootAuth()
{
// Inject Decoy's auth config
Config::set('auth.guards.decoy', [
'driver' => 'session',
'provider' => 'decoy',
]);
Config::set('auth.providers.decoy', [
'driver' => 'eloquent',
'model' => Models\Admin::c... | php | public function bootAuth()
{
// Inject Decoy's auth config
Config::set('auth.guards.decoy', [
'driver' => 'session',
'provider' => 'decoy',
]);
Config::set('auth.providers.decoy', [
'driver' => 'eloquent',
'model' => Models\Admin::c... | [
"public",
"function",
"bootAuth",
"(",
")",
"{",
"// Inject Decoy's auth config",
"Config",
"::",
"set",
"(",
"'auth.guards.decoy'",
",",
"[",
"'driver'",
"=>",
"'session'",
",",
"'provider'",
"=>",
"'decoy'",
",",
"]",
")",
";",
"Config",
"::",
"set",
"(",
... | Boot Decoy's auth integration
@return void | [
"Boot",
"Decoy",
"s",
"auth",
"integration"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/ServiceProvider.php#L137-L159 |
30,616 | BKWLD/decoy | classes/ServiceProvider.php | ServiceProvider.delegateAdminObservers | protected function delegateAdminObservers()
{
$this->app['events']->listen('eloquent.saving:*',
'Bkwld\Decoy\Observers\Localize');
$this->app['events']->listen('eloquent.saving:*',
'Bkwld\Decoy\Observers\Encoding@onSaving');
$this->app['events']->listen('eloquent.save... | php | protected function delegateAdminObservers()
{
$this->app['events']->listen('eloquent.saving:*',
'Bkwld\Decoy\Observers\Localize');
$this->app['events']->listen('eloquent.saving:*',
'Bkwld\Decoy\Observers\Encoding@onSaving');
$this->app['events']->listen('eloquent.save... | [
"protected",
"function",
"delegateAdminObservers",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'events'",
"]",
"->",
"listen",
"(",
"'eloquent.saving:*'",
",",
"'Bkwld\\Decoy\\Observers\\Localize'",
")",
";",
"$",
"this",
"->",
"app",
"[",
"'events'",
"]",
... | Delegate events to Decoy observers
@return void | [
"Delegate",
"events",
"to",
"Decoy",
"observers"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/ServiceProvider.php#L191-L203 |
30,617 | BKWLD/decoy | classes/ServiceProvider.php | ServiceProvider.registerPackages | private function registerPackages()
{
// Form field generation
AliasLoader::getInstance()->alias('Former', \Former\Facades\Former::class);
$this->app->register('Former\FormerServiceProvider');
// Image resizing
AliasLoader::getInstance()->alias('Croppa', \Bkwld\Croppa\Facade... | php | private function registerPackages()
{
// Form field generation
AliasLoader::getInstance()->alias('Former', \Former\Facades\Former::class);
$this->app->register('Former\FormerServiceProvider');
// Image resizing
AliasLoader::getInstance()->alias('Croppa', \Bkwld\Croppa\Facade... | [
"private",
"function",
"registerPackages",
"(",
")",
"{",
"// Form field generation",
"AliasLoader",
"::",
"getInstance",
"(",
")",
"->",
"alias",
"(",
"'Former'",
",",
"\\",
"Former",
"\\",
"Facades",
"\\",
"Former",
"::",
"class",
")",
";",
"$",
"this",
"-... | Register external dependencies | [
"Register",
"external",
"dependencies"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/ServiceProvider.php#L330-L358 |
30,618 | BKWLD/decoy | classes/Models/Traits/Exportable.php | Exportable.mapExportAttributes | protected function mapExportAttributes($attributes)
{
return collect($attributes->toArray())->map(function($value, $key) {
return $this->mapExportAttribute($value, $key);
})->toArray();
} | php | protected function mapExportAttributes($attributes)
{
return collect($attributes->toArray())->map(function($value, $key) {
return $this->mapExportAttribute($value, $key);
})->toArray();
} | [
"protected",
"function",
"mapExportAttributes",
"(",
"$",
"attributes",
")",
"{",
"return",
"collect",
"(",
"$",
"attributes",
"->",
"toArray",
"(",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"$",
"t... | Massage attribute values. The CSV needs a flat array.
@return array | [
"Massage",
"attribute",
"values",
".",
"The",
"CSV",
"needs",
"a",
"flat",
"array",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Exportable.php#L64-L69 |
30,619 | BKWLD/decoy | classes/Models/Traits/Exportable.php | Exportable.mapExportAttribute | protected function mapExportAttribute($value, $key)
{
// If an images relationship
if ($key == 'images') {
return implode(',', array_map(function($image) {
return $image['file'];
}, $value));
}
// If another array...
if (is_array($valu... | php | protected function mapExportAttribute($value, $key)
{
// If an images relationship
if ($key == 'images') {
return implode(',', array_map(function($image) {
return $image['file'];
}, $value));
}
// If another array...
if (is_array($valu... | [
"protected",
"function",
"mapExportAttribute",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"// If an images relationship",
"if",
"(",
"$",
"key",
"==",
"'images'",
")",
"{",
"return",
"implode",
"(",
"','",
",",
"array_map",
"(",
"function",
"(",
"$",
"i... | Massage attribute values for export
@return scalar | [
"Massage",
"attribute",
"values",
"for",
"export"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Exportable.php#L76-L102 |
30,620 | BKWLD/decoy | classes/Models/Traits/Exportable.php | Exportable.makeCsvHeaderNames | public function makeCsvHeaderNames()
{
$headers = array_keys($this->forExport());
return array_map(function($key) {
switch($key) {
// id must be lowercase for opening in excel
// https://annalear.ca/2010/06/10/why-excel-thinks-your-csv-is-a-sylk/
... | php | public function makeCsvHeaderNames()
{
$headers = array_keys($this->forExport());
return array_map(function($key) {
switch($key) {
// id must be lowercase for opening in excel
// https://annalear.ca/2010/06/10/why-excel-thinks-your-csv-is-a-sylk/
... | [
"public",
"function",
"makeCsvHeaderNames",
"(",
")",
"{",
"$",
"headers",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"forExport",
"(",
")",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"key",
")",
"{",
"switch",
"(",
"$",
"key",
")",
... | Make the header the CSV header row
@return array | [
"Make",
"the",
"header",
"the",
"CSV",
"header",
"row"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Exportable.php#L109-L130 |
30,621 | BKWLD/decoy | classes/Models/Image.php | Image.deletedBecauseEmpty | public function deletedBecauseEmpty()
{
if ($file = $this->getAttributeValue('file')) {
return false;
}
if ($this->exists) {
$this->delete();
}
return true;
} | php | public function deletedBecauseEmpty()
{
if ($file = $this->getAttributeValue('file')) {
return false;
}
if ($this->exists) {
$this->delete();
}
return true;
} | [
"public",
"function",
"deletedBecauseEmpty",
"(",
")",
"{",
"if",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getAttributeValue",
"(",
"'file'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"exists",
")",
"{",
"$",
"this",... | If the file attribtue is empty, this Image has been marked for deletion.
Return true to signal the image was deleted
@return bool | [
"If",
"the",
"file",
"attribtue",
"is",
"empty",
"this",
"Image",
"has",
"been",
"marked",
"for",
"deletion",
".",
"Return",
"true",
"to",
"signal",
"the",
"image",
"was",
"deleted"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Image.php#L169-L180 |
30,622 | BKWLD/decoy | classes/Models/Image.php | Image.populateFileMeta | public function populateFileMeta()
{
$file = $this->getAttributeValue('file');
if (!is_a($file, UploadedFile::class)) {
return;
}
$size = getimagesize($file->getPathname());
$this->fill([
'file_type' => $this->guessFileType($file),
'file_si... | php | public function populateFileMeta()
{
$file = $this->getAttributeValue('file');
if (!is_a($file, UploadedFile::class)) {
return;
}
$size = getimagesize($file->getPathname());
$this->fill([
'file_type' => $this->guessFileType($file),
'file_si... | [
"public",
"function",
"populateFileMeta",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getAttributeValue",
"(",
"'file'",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"file",
",",
"UploadedFile",
"::",
"class",
")",
")",
"{",
"return",
";",
"}... | Store file meta info in the database if a new File object is present
@return void | [
"Store",
"file",
"meta",
"info",
"in",
"the",
"database",
"if",
"a",
"new",
"File",
"object",
"is",
"present"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Image.php#L187-L200 |
30,623 | BKWLD/decoy | classes/Models/Image.php | Image.crop | public function crop($width = null, $height = null, $options = null)
{
$this->config = [
'width' => $width,
'height' => $height,
'options' => $options,
];
return $this;
} | php | public function crop($width = null, $height = null, $options = null)
{
$this->config = [
'width' => $width,
'height' => $height,
'options' => $options,
];
return $this;
} | [
"public",
"function",
"crop",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"[",
"'width'",
"=>",
"$",
"width",
",",
"'height'",
"=>",
"$",
"height",
... | Set the crop dimenions
@param integer $width
@param integer $height
@param array $options Croppa options array
@return $this | [
"Set",
"the",
"crop",
"dimenions"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Image.php#L241-L250 |
30,624 | BKWLD/decoy | classes/Models/Image.php | Image.getConfig | public function getConfig()
{
// Create default keys for the config
$config = array_merge([
'width' => null,
'height' => null,
'options' => null,
], $this->config);
// Add crops
if ($crop = $this->getAttributeValue('crop_box')) {
... | php | public function getConfig()
{
// Create default keys for the config
$config = array_merge([
'width' => null,
'height' => null,
'options' => null,
], $this->config);
// Add crops
if ($crop = $this->getAttributeValue('crop_box')) {
... | [
"public",
"function",
"getConfig",
"(",
")",
"{",
"// Create default keys for the config",
"$",
"config",
"=",
"array_merge",
"(",
"[",
"'width'",
"=>",
"null",
",",
"'height'",
"=>",
"null",
",",
"'options'",
"=>",
"null",
",",
"]",
",",
"$",
"this",
"->",
... | Get the config, merging defaults in so that all keys in the array are
present. This also applies the crop choices from the DB.
@return array | [
"Get",
"the",
"config",
"merging",
"defaults",
"in",
"so",
"that",
"all",
"keys",
"in",
"the",
"array",
"are",
"present",
".",
"This",
"also",
"applies",
"the",
"crop",
"choices",
"from",
"the",
"DB",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Image.php#L258-L282 |
30,625 | BKWLD/decoy | classes/Models/Image.php | Image.urlify | public function urlify($size, $multiplier = 1)
{
// Get fluent config
$config = $this->getConfig();
// Setup vars
$size = $this->sizes[$size];
$scale = $size[0] / $this->bench;
$width = $height = null;
// Figure out percentage sizes. First one of the dimens... | php | public function urlify($size, $multiplier = 1)
{
// Get fluent config
$config = $this->getConfig();
// Setup vars
$size = $this->sizes[$size];
$scale = $size[0] / $this->bench;
$width = $height = null;
// Figure out percentage sizes. First one of the dimens... | [
"public",
"function",
"urlify",
"(",
"$",
"size",
",",
"$",
"multiplier",
"=",
"1",
")",
"{",
"// Get fluent config",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"// Setup vars",
"$",
"size",
"=",
"$",
"this",
"->",
"sizes",
"[",... | Make paths full URLs so these can be used directly in APIs or for Open
Graph tags, for example.
@param string $size
@param number $scale
@return string url | [
"Make",
"paths",
"full",
"URLs",
"so",
"these",
"can",
"be",
"used",
"directly",
"in",
"APIs",
"or",
"for",
"Open",
"Graph",
"tags",
"for",
"example",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Image.php#L482-L516 |
30,626 | BKWLD/decoy | classes/Commands/Generate.php | Generate.generateModel | private function generateModel()
{
// Figure out the naming
$model = ucfirst($this->argument('model'));
$path = 'app/'.$model.'.php';
$file = base_path().'/'.$path;
// Copy the stub over
if (file_exists($file)) {
return $this->comment('Model already exist... | php | private function generateModel()
{
// Figure out the naming
$model = ucfirst($this->argument('model'));
$path = 'app/'.$model.'.php';
$file = base_path().'/'.$path;
// Copy the stub over
if (file_exists($file)) {
return $this->comment('Model already exist... | [
"private",
"function",
"generateModel",
"(",
")",
"{",
"// Figure out the naming",
"$",
"model",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"argument",
"(",
"'model'",
")",
")",
";",
"$",
"path",
"=",
"'app/'",
".",
"$",
"model",
".",
"'.php'",
";",
"$",
... | Create the model file | [
"Create",
"the",
"model",
"file"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Commands/Generate.php#L49-L62 |
30,627 | BKWLD/decoy | classes/Commands/Generate.php | Generate.generateView | private function generateView()
{
// Figure out the naming
$path = 'resources/views/admin/'
. Str::plural(Str::snake($this->argument('model')))
. '/edit.haml';
$file = base_path().'/'.$path;
// Copy the stub over
if (!file_exists(dirname($file))) {
... | php | private function generateView()
{
// Figure out the naming
$path = 'resources/views/admin/'
. Str::plural(Str::snake($this->argument('model')))
. '/edit.haml';
$file = base_path().'/'.$path;
// Copy the stub over
if (!file_exists(dirname($file))) {
... | [
"private",
"function",
"generateView",
"(",
")",
"{",
"// Figure out the naming",
"$",
"path",
"=",
"'resources/views/admin/'",
".",
"Str",
"::",
"plural",
"(",
"Str",
"::",
"snake",
"(",
"$",
"this",
"->",
"argument",
"(",
"'model'",
")",
")",
")",
".",
"... | Create the view file | [
"Create",
"the",
"view",
"file"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Commands/Generate.php#L67-L84 |
30,628 | BKWLD/decoy | classes/Commands/Generate.php | Generate.generateController | private function generateController()
{
// Figure out the naming
$controller = Str::plural(ucfirst($this->argument('model')));
$path = 'app/Http/Controllers/Admin/'.$controller.'.php';
$file = base_path().'/'.$path;
// Copy the stub over
if (!file_exists(dirname($fil... | php | private function generateController()
{
// Figure out the naming
$controller = Str::plural(ucfirst($this->argument('model')));
$path = 'app/Http/Controllers/Admin/'.$controller.'.php';
$file = base_path().'/'.$path;
// Copy the stub over
if (!file_exists(dirname($fil... | [
"private",
"function",
"generateController",
"(",
")",
"{",
"// Figure out the naming",
"$",
"controller",
"=",
"Str",
"::",
"plural",
"(",
"ucfirst",
"(",
"$",
"this",
"->",
"argument",
"(",
"'model'",
")",
")",
")",
";",
"$",
"path",
"=",
"'app/Http/Contro... | Create the controller file | [
"Create",
"the",
"controller",
"file"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Commands/Generate.php#L89-L105 |
30,629 | BKWLD/decoy | classes/Input/Localize.php | Localize.item | public function item($item)
{
if (!$this->model) {
$this->model = get_class($item);
}
$this->item = $item;
return $this;
} | php | public function item($item)
{
if (!$this->model) {
$this->model = get_class($item);
}
$this->item = $item;
return $this;
} | [
"public",
"function",
"item",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"model",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"get_class",
"(",
"$",
"item",
")",
";",
"}",
"$",
"this",
"->",
"item",
"=",
"$",
"item",
";",
"... | Store a model instance
@param Illuminate\Database\Eloquent\Model $item
@return $this | [
"Store",
"a",
"model",
"instance"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Input/Localize.php#L44-L53 |
30,630 | BKWLD/decoy | classes/Input/Localize.php | Localize.hidden | public function hidden()
{
$class = $this->model; // Must be a local var to test
// There aren't multiple locales specified
if (count(config('decoy.site.locales')) <= 1 ) return true;
// We're editing a model with no locale attribute
if ($this->item && !$this->item->locale)... | php | public function hidden()
{
$class = $this->model; // Must be a local var to test
// There aren't multiple locales specified
if (count(config('decoy.site.locales')) <= 1 ) return true;
// We're editing a model with no locale attribute
if ($this->item && !$this->item->locale)... | [
"public",
"function",
"hidden",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"model",
";",
"// Must be a local var to test",
"// There aren't multiple locales specified",
"if",
"(",
"count",
"(",
"config",
"(",
"'decoy.site.locales'",
")",
")",
"<=",
"1",
... | Check if the localize UI should be displayed
@return boolean | [
"Check",
"if",
"the",
"localize",
"UI",
"should",
"be",
"displayed"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Input/Localize.php#L86-L110 |
30,631 | BKWLD/decoy | classes/Input/Localize.php | Localize.localizableLocales | public function localizableLocales()
{
// Keep only locales that don't exist in ...
return array_diff_key(
Config::get('decoy.site.locales'),
// ... the locales of other localizations ...
$this->other()->pluck('locale')->flip()->toArray(),
// ... and... | php | public function localizableLocales()
{
// Keep only locales that don't exist in ...
return array_diff_key(
Config::get('decoy.site.locales'),
// ... the locales of other localizations ...
$this->other()->pluck('locale')->flip()->toArray(),
// ... and... | [
"public",
"function",
"localizableLocales",
"(",
")",
"{",
"// Keep only locales that don't exist in ...",
"return",
"array_diff_key",
"(",
"Config",
"::",
"get",
"(",
"'decoy.site.locales'",
")",
",",
"// ... the locales of other localizations ...",
"$",
"this",
"->",
"oth... | Get a hash of locales that are available for the item
@return array | [
"Get",
"a",
"hash",
"of",
"locales",
"that",
"are",
"available",
"for",
"the",
"item"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Input/Localize.php#L117-L129 |
30,632 | BKWLD/decoy | classes/Input/Localize.php | Localize.other | public function other()
{
if ($this->other_localizations === null) {
$this->other_localizations = $this->item->otherLocalizations()->get();
}
return $this->other_localizations;
} | php | public function other()
{
if ($this->other_localizations === null) {
$this->other_localizations = $this->item->otherLocalizations()->get();
}
return $this->other_localizations;
} | [
"public",
"function",
"other",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"other_localizations",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"other_localizations",
"=",
"$",
"this",
"->",
"item",
"->",
"otherLocalizations",
"(",
")",
"->",
"get",
"(",
... | Get other localizations, storing them internally for use in multiple places
@return Illuminate\Database\Eloquent\Collection | [
"Get",
"other",
"localizations",
"storing",
"them",
"internally",
"for",
"use",
"in",
"multiple",
"places"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Input/Localize.php#L136-L143 |
30,633 | BKWLD/decoy | classes/Controllers/Admins.php | Admins.search | public function search()
{
$options = [
'first_name' => [
'label' => __('decoy::admins.controller.search.first_name'),
'type' => 'text',
],
'last_name' => [
'label' => __('decoy::admins.controller.search.last_name'),
... | php | public function search()
{
$options = [
'first_name' => [
'label' => __('decoy::admins.controller.search.first_name'),
'type' => 'text',
],
'last_name' => [
'label' => __('decoy::admins.controller.search.last_name'),
... | [
"public",
"function",
"search",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"'first_name'",
"=>",
"[",
"'label'",
"=>",
"__",
"(",
"'decoy::admins.controller.search.first_name'",
")",
",",
"'type'",
"=>",
"'text'",
",",
"]",
",",
"'last_name'",
"=>",
"[",
"'lab... | Make search options dependent on whether the site is using roles
@return array | [
"Make",
"search",
"options",
"dependent",
"on",
"whether",
"the",
"site",
"is",
"using",
"roles"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Admins.php#L26-L60 |
30,634 | BKWLD/decoy | classes/Controllers/Admins.php | Admins.update | public function update($id)
{
// Encorce permissions on updating ones own role
if (!app('decoy.user')->can('update', 'admins') && Request::has('role')) {
throw new AccessDeniedHttpException;
}
// If the password is empty, remove the key from the input so it isn't cleared... | php | public function update($id)
{
// Encorce permissions on updating ones own role
if (!app('decoy.user')->can('update', 'admins') && Request::has('role')) {
throw new AccessDeniedHttpException;
}
// If the password is empty, remove the key from the input so it isn't cleared... | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"// Encorce permissions on updating ones own role",
"if",
"(",
"!",
"app",
"(",
"'decoy.user'",
")",
"->",
"can",
"(",
"'update'",
",",
"'admins'",
")",
"&&",
"Request",
"::",
"has",
"(",
"'role'",
")... | Don't let unauthorize folks update their role by passing in role values
in the GET
@param int $id Model key
@throws AccessDeniedHttpException
@return Symfony\Component\HttpFoundation\Response | [
"Don",
"t",
"let",
"unauthorize",
"folks",
"update",
"their",
"role",
"by",
"passing",
"in",
"role",
"values",
"in",
"the",
"GET"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Admins.php#L110-L124 |
30,635 | BKWLD/decoy | classes/Controllers/Admins.php | Admins.enable | public function enable($id)
{
if (!app('decoy.user')->can('grant', 'admins')) {
throw new AccessDeniedHttpException;
}
if (!($admin = Admin::find($id))) {
return App::abort(404);
}
$admin->active = 1;
$admin->save();
return Redirect:... | php | public function enable($id)
{
if (!app('decoy.user')->can('grant', 'admins')) {
throw new AccessDeniedHttpException;
}
if (!($admin = Admin::find($id))) {
return App::abort(404);
}
$admin->active = 1;
$admin->save();
return Redirect:... | [
"public",
"function",
"enable",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"app",
"(",
"'decoy.user'",
")",
"->",
"can",
"(",
"'grant'",
",",
"'admins'",
")",
")",
"{",
"throw",
"new",
"AccessDeniedHttpException",
";",
"}",
"if",
"(",
"!",
"(",
"$",
... | Enable the admin
@return Illuminate\Http\RedirectResponse | [
"Enable",
"the",
"admin"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Admins.php#L152-L166 |
30,636 | BKWLD/decoy | classes/Controllers/Base.php | Base.init | private function init()
{
// Set the layout from the Config file
$this->layout = View::make(config('decoy.core.layout'));
// Store the controller class for routing
$this->controller = get_class($this);
// Get the controller name
$controller_name = $this->controllerN... | php | private function init()
{
// Set the layout from the Config file
$this->layout = View::make(config('decoy.core.layout'));
// Store the controller class for routing
$this->controller = get_class($this);
// Get the controller name
$controller_name = $this->controllerN... | [
"private",
"function",
"init",
"(",
")",
"{",
"// Set the layout from the Config file",
"$",
"this",
"->",
"layout",
"=",
"View",
"::",
"make",
"(",
"config",
"(",
"'decoy.core.layout'",
")",
")",
";",
"// Store the controller class for routing",
"$",
"this",
"->",
... | Populate the controller's protected properties
@return void | [
"Populate",
"the",
"controller",
"s",
"protected",
"properties"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L180-L218 |
30,637 | BKWLD/decoy | classes/Controllers/Base.php | Base.title | public function title($controller_name = null)
{
// For when this is invoked as a getter for $this->title
if (!$controller_name) {
return $this->title;
}
// Do the de-studlying
preg_match_all('#[a-z]+|[A-Z][a-z]*#', $controller_name, $matches);
return i... | php | public function title($controller_name = null)
{
// For when this is invoked as a getter for $this->title
if (!$controller_name) {
return $this->title;
}
// Do the de-studlying
preg_match_all('#[a-z]+|[A-Z][a-z]*#', $controller_name, $matches);
return i... | [
"public",
"function",
"title",
"(",
"$",
"controller_name",
"=",
"null",
")",
"{",
"// For when this is invoked as a getter for $this->title",
"if",
"(",
"!",
"$",
"controller_name",
")",
"{",
"return",
"$",
"this",
"->",
"title",
";",
"}",
"// Do the de-studlying",... | Get the title for the controller based on the controller name. Basically,
it's a de-studdly-er
@param string $controller_name ex: 'Admins' or 'CarLovers'
@return string ex: 'Admins' or 'Car Lovers' | [
"Get",
"the",
"title",
"for",
"the",
"controller",
"based",
"on",
"the",
"controller",
"name",
".",
"Basically",
"it",
"s",
"a",
"de",
"-",
"studdly",
"-",
"er"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L247-L258 |
30,638 | BKWLD/decoy | classes/Controllers/Base.php | Base.detailPath | public function detailPath($class)
{
// Remove Decoy from the class
$path = str_replace('Bkwld\Decoy\Controllers\\', '', $class, $is_decoy);
// Remove the App controller prefix
$path = str_replace('App\Http\Controllers\\', '', $path);
// Break up all the remainder of the cl... | php | public function detailPath($class)
{
// Remove Decoy from the class
$path = str_replace('Bkwld\Decoy\Controllers\\', '', $class, $is_decoy);
// Remove the App controller prefix
$path = str_replace('App\Http\Controllers\\', '', $path);
// Break up all the remainder of the cl... | [
"public",
"function",
"detailPath",
"(",
"$",
"class",
")",
"{",
"// Remove Decoy from the class",
"$",
"path",
"=",
"str_replace",
"(",
"'Bkwld\\Decoy\\Controllers\\\\'",
",",
"''",
",",
"$",
"class",
",",
"$",
"is_decoy",
")",
";",
"// Remove the App controller pr... | Get the directory for the detail views. It's based off the controller name.
This is basically a conversion to snake case from studyly case
@param string $class ex: 'Admin\NewsController'
@return string ex: admins.edit or car_lovers.edit | [
"Get",
"the",
"directory",
"for",
"the",
"detail",
"views",
".",
"It",
"s",
"based",
"off",
"the",
"controller",
"name",
".",
"This",
"is",
"basically",
"a",
"conversion",
"to",
"snake",
"case",
"from",
"studyly",
"case"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L311-L336 |
30,639 | BKWLD/decoy | classes/Controllers/Base.php | Base.parent | public function parent($parent)
{
// Save out the passed reference
$this->parent = $parent;
// Save out sub properties that I hope to deprecate
$this->parent_model = get_class($this->parent);
$this->parent_controller = Decoy::controllerForModel($this->parent_model);
... | php | public function parent($parent)
{
// Save out the passed reference
$this->parent = $parent;
// Save out sub properties that I hope to deprecate
$this->parent_model = get_class($this->parent);
$this->parent_controller = Decoy::controllerForModel($this->parent_model);
... | [
"public",
"function",
"parent",
"(",
"$",
"parent",
")",
"{",
"// Save out the passed reference",
"$",
"this",
"->",
"parent",
"=",
"$",
"parent",
";",
"// Save out sub properties that I hope to deprecate",
"$",
"this",
"->",
"parent_model",
"=",
"get_class",
"(",
"... | Give this controller a parent model instance. For instance, this makes the
index view a listing of just the children of the parent.
@param Illuminate\Database\Eloquent\Model $parent
@return $this | [
"Give",
"this",
"controller",
"a",
"parent",
"model",
"instance",
".",
"For",
"instance",
"this",
"makes",
"the",
"index",
"view",
"a",
"listing",
"of",
"just",
"the",
"children",
"of",
"the",
"parent",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L360-L397 |
30,640 | BKWLD/decoy | classes/Controllers/Base.php | Base.index | public function index()
{
// Look for overriden views
$this->overrideViews();
// Get models to show
$results = $this->makeIndexQuery()->paginate($this->perPage());
// Render the view using the `listing` builder
$listing = Listing::createFromController($this, $result... | php | public function index()
{
// Look for overriden views
$this->overrideViews();
// Get models to show
$results = $this->makeIndexQuery()->paginate($this->perPage());
// Render the view using the `listing` builder
$listing = Listing::createFromController($this, $result... | [
"public",
"function",
"index",
"(",
")",
"{",
"// Look for overriden views",
"$",
"this",
"->",
"overrideViews",
"(",
")",
";",
"// Get models to show",
"$",
"results",
"=",
"$",
"this",
"->",
"makeIndexQuery",
"(",
")",
"->",
"paginate",
"(",
"$",
"this",
"... | Show an index, listing page. Sets view via the layout.
@return Illuminate\Contracts\View\Factory | [
"Show",
"an",
"index",
"listing",
"page",
".",
"Sets",
"view",
"via",
"the",
"layout",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L440-L459 |
30,641 | BKWLD/decoy | classes/Controllers/Base.php | Base.create | public function create()
{
// Look for overriden views
$this->overrideViews();
// Pass validation through
Former::withRules($this->getRules());
// Initialize localization
with($localize = new Localize)
->model($this->model)
->title(Str::singu... | php | public function create()
{
// Look for overriden views
$this->overrideViews();
// Pass validation through
Former::withRules($this->getRules());
// Initialize localization
with($localize = new Localize)
->model($this->model)
->title(Str::singu... | [
"public",
"function",
"create",
"(",
")",
"{",
"// Look for overriden views",
"$",
"this",
"->",
"overrideViews",
"(",
")",
";",
"// Pass validation through",
"Former",
"::",
"withRules",
"(",
"$",
"this",
"->",
"getRules",
"(",
")",
")",
";",
"// Initialize loc... | Show the create form. Sets view via the layout.
@return Illuminate\Contracts\View\Factory | [
"Show",
"the",
"create",
"form",
".",
"Sets",
"view",
"via",
"the",
"layout",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L466-L492 |
30,642 | BKWLD/decoy | classes/Controllers/Base.php | Base.store | public function store()
{
// Create a new object
$item = new $this->model;
// Remove nested model data from input and prepare to insert on save
$input = (new NestedModels)->relateTo($item);
// Hydrate the object
$item->fill($input);
// Validate and save.
... | php | public function store()
{
// Create a new object
$item = new $this->model;
// Remove nested model data from input and prepare to insert on save
$input = (new NestedModels)->relateTo($item);
// Hydrate the object
$item->fill($input);
// Validate and save.
... | [
"public",
"function",
"store",
"(",
")",
"{",
"// Create a new object",
"$",
"item",
"=",
"new",
"$",
"this",
"->",
"model",
";",
"// Remove nested model data from input and prepare to insert on save",
"$",
"input",
"=",
"(",
"new",
"NestedModels",
")",
"->",
"relat... | Store a new record
@return Symfony\Component\HttpFoundation\Response Redirect to edit view | [
"Store",
"a",
"new",
"record"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L499-L525 |
30,643 | BKWLD/decoy | classes/Controllers/Base.php | Base.edit | public function edit($id)
{
// Get the model instance
$item = $this->findOrFail($id);
// Respond to AJAX requests for a single item with JSON
if (Request::ajax()) {
return Response::json($item);
}
// Look for overriden views
$this->overrideViews(... | php | public function edit($id)
{
// Get the model instance
$item = $this->findOrFail($id);
// Respond to AJAX requests for a single item with JSON
if (Request::ajax()) {
return Response::json($item);
}
// Look for overriden views
$this->overrideViews(... | [
"public",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"// Get the model instance",
"$",
"item",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// Respond to AJAX requests for a single item with JSON",
"if",
"(",
"Request",
"::",
"ajax",
"(",
... | Show the edit form. Sets view via the layout.
@param int $id Model key
@return Illuminate\Contracts\View\Factory | [
"Show",
"the",
"edit",
"form",
".",
"Sets",
"view",
"via",
"the",
"layout",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L533-L568 |
30,644 | BKWLD/decoy | classes/Controllers/Base.php | Base.destroy | public function destroy($id)
{
// Find the item
$item = $this->findOrFail($id);
// Delete row (this should trigger file attachment deletes as well)
$item->delete();
// As long as not an ajax request, go back to the parent directory of the referrer
if (Request::ajax(... | php | public function destroy($id)
{
// Find the item
$item = $this->findOrFail($id);
// Delete row (this should trigger file attachment deletes as well)
$item->delete();
// As long as not an ajax request, go back to the parent directory of the referrer
if (Request::ajax(... | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"// Find the item",
"$",
"item",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// Delete row (this should trigger file attachment deletes as well)",
"$",
"item",
"->",
"delete",
"(",
"... | Destroy a record
@param int $id Model key
@return Symfony\Component\HttpFoundation\Response Redirect to listing | [
"Destroy",
"a",
"record"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L619-L634 |
30,645 | BKWLD/decoy | classes/Controllers/Base.php | Base.duplicate | public function duplicate($id)
{
// Find the source item
$src = $this->findOrFail($id);
if (empty($src->cloneable)) {
return App::abort(404);
}
// Duplicate using Bkwld\Cloner
$new = $src->duplicate();
// Don't make duplicates public
if (... | php | public function duplicate($id)
{
// Find the source item
$src = $this->findOrFail($id);
if (empty($src->cloneable)) {
return App::abort(404);
}
// Duplicate using Bkwld\Cloner
$new = $src->duplicate();
// Don't make duplicates public
if (... | [
"public",
"function",
"duplicate",
"(",
"$",
"id",
")",
"{",
"// Find the source item",
"$",
"src",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"src",
"->",
"cloneable",
")",
")",
"{",
"return",
"App"... | Duplicate a record
@param int $id Model key
@return Symfony\Component\HttpFoundation\Response Redirect to new record | [
"Duplicate",
"a",
"record"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L646-L684 |
30,646 | BKWLD/decoy | classes/Controllers/Base.php | Base.autocomplete | public function autocomplete()
{
// Do nothing if the query is too short
if (strlen(request('query')) < 1) {
return Response::json();
}
// Get an instance so the title attributes can be found. If none are found,
// then there are no results, so bounce
if... | php | public function autocomplete()
{
// Do nothing if the query is too short
if (strlen(request('query')) < 1) {
return Response::json();
}
// Get an instance so the title attributes can be found. If none are found,
// then there are no results, so bounce
if... | [
"public",
"function",
"autocomplete",
"(",
")",
"{",
"// Do nothing if the query is too short",
"if",
"(",
"strlen",
"(",
"request",
"(",
"'query'",
")",
")",
"<",
"1",
")",
"{",
"return",
"Response",
"::",
"json",
"(",
")",
";",
"}",
"// Get an instance so th... | List as JSON for autocomplete widgets
@return Illuminate\Http\Response JSON | [
"List",
"as",
"JSON",
"for",
"autocomplete",
"widgets"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L695-L747 |
30,647 | BKWLD/decoy | classes/Controllers/Base.php | Base.autocompleteViewVars | public function autocompleteViewVars()
{
if (!$this->parent) {
return [];
}
$parent_controller = new $this->parent_controller;
return [
'parent_id' => $this->parent->getKey(),
'parent_controller' => $this->parent_controller,
'parent_c... | php | public function autocompleteViewVars()
{
if (!$this->parent) {
return [];
}
$parent_controller = new $this->parent_controller;
return [
'parent_id' => $this->parent->getKey(),
'parent_controller' => $this->parent_controller,
'parent_c... | [
"public",
"function",
"autocompleteViewVars",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"parent",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"parent_controller",
"=",
"new",
"$",
"this",
"->",
"parent_controller",
";",
"return",
"[",
"'parent_i... | Return key-val pairs needed for view partials related to many to many
autocompletes
@return array key-val pairs | [
"Return",
"key",
"-",
"val",
"pairs",
"needed",
"for",
"view",
"partials",
"related",
"to",
"many",
"to",
"many",
"autocompletes"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L755-L770 |
30,648 | BKWLD/decoy | classes/Controllers/Base.php | Base.attach | public function attach($id)
{
// Require there to be a parent id and a valid id for the resource
$item = $this->findOrFail($id);
// Do the attach
$item->fireDecoyEvent('attaching', [$item, $this->parent]);
$item->{$this->self_to_parent}()->attach($this->parent);
$ite... | php | public function attach($id)
{
// Require there to be a parent id and a valid id for the resource
$item = $this->findOrFail($id);
// Do the attach
$item->fireDecoyEvent('attaching', [$item, $this->parent]);
$item->{$this->self_to_parent}()->attach($this->parent);
$ite... | [
"public",
"function",
"attach",
"(",
"$",
"id",
")",
"{",
"// Require there to be a parent id and a valid id for the resource",
"$",
"item",
"=",
"$",
"this",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"// Do the attach",
"$",
"item",
"->",
"fireDecoyEvent",
"(... | Attach a model to a parent_id, like with a many to many style
autocomplete widget
@param int $id The id of the parent model
@return Illuminate\Http\Response JSON | [
"Attach",
"a",
"model",
"to",
"a",
"parent_id",
"like",
"with",
"a",
"many",
"to",
"many",
"style",
"autocomplete",
"widget"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L779-L791 |
30,649 | BKWLD/decoy | classes/Controllers/Base.php | Base.remove | public function remove($id)
{
// Support removing many ids at once
$ids = Request::has('ids') ? explode(',', request('ids')) : [$id];
// Get the model instances for each id, for the purpose of event firing
$items = array_map(function ($id) {
return $this->findOrFail($id)... | php | public function remove($id)
{
// Support removing many ids at once
$ids = Request::has('ids') ? explode(',', request('ids')) : [$id];
// Get the model instances for each id, for the purpose of event firing
$items = array_map(function ($id) {
return $this->findOrFail($id)... | [
"public",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"// Support removing many ids at once",
"$",
"ids",
"=",
"Request",
"::",
"has",
"(",
"'ids'",
")",
"?",
"explode",
"(",
"','",
",",
"request",
"(",
"'ids'",
")",
")",
":",
"[",
"$",
"id",
"]",
... | Remove a relationship. Very similar to delete, except that we're
not actually deleting from the database
@param mixed $id One or many (commaa delimited) parent ids
@return Illuminate\Http\Response Either a JSON or Redirect response | [
"Remove",
"a",
"relationship",
".",
"Very",
"similar",
"to",
"delete",
"except",
"that",
"we",
"re",
"not",
"actually",
"deleting",
"from",
"the",
"database"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L799-L825 |
30,650 | BKWLD/decoy | classes/Controllers/Base.php | Base.makeIndexQuery | protected function makeIndexQuery()
{
// Open up the query. We can assume that Model has an ordered() function
// because it's defined on Decoy's Base_Model
$query = $this->parent ?
$this->parentRelation()->ordered() :
call_user_func([$this->model, 'ordered']);
... | php | protected function makeIndexQuery()
{
// Open up the query. We can assume that Model has an ordered() function
// because it's defined on Decoy's Base_Model
$query = $this->parent ?
$this->parentRelation()->ordered() :
call_user_func([$this->model, 'ordered']);
... | [
"protected",
"function",
"makeIndexQuery",
"(",
")",
"{",
"// Open up the query. We can assume that Model has an ordered() function",
"// because it's defined on Decoy's Base_Model",
"$",
"query",
"=",
"$",
"this",
"->",
"parent",
"?",
"$",
"this",
"->",
"parentRelation",
"("... | Make the index query, including applying a search
@return \Illuminate\Database\Eloquent\Builder | [
"Make",
"the",
"index",
"query",
"including",
"applying",
"a",
"search"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L836-L853 |
30,651 | BKWLD/decoy | classes/Controllers/Base.php | Base.findOrFail | protected function findOrFail($id)
{
$model = $this->model;
if ($this->withTrashed()) {
return $model::withTrashed()->findOrFail($id);
} else {
return $model::findOrFail($id);
}
} | php | protected function findOrFail($id)
{
$model = $this->model;
if ($this->withTrashed()) {
return $model::withTrashed()->findOrFail($id);
} else {
return $model::findOrFail($id);
}
} | [
"protected",
"function",
"findOrFail",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"$",
"this",
"->",
"withTrashed",
"(",
")",
")",
"{",
"return",
"$",
"model",
"::",
"withTrashed",
"(",
")",
"->",
"find... | Helper for getting a model instance by ID
@param scalar $id
@return Eloquent\Model | [
"Helper",
"for",
"getting",
"a",
"model",
"instance",
"by",
"ID"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L861-L869 |
30,652 | BKWLD/decoy | classes/Controllers/Base.php | Base.validate | protected function validate($data, $rules = null, $messages = [])
{
// A request may be passed in when using Laravel traits, like how resetting
// passwords work. Get the input from it
if (is_a($data, \Illuminate\Http\Request::class)) {
$data = $data->input();
}
... | php | protected function validate($data, $rules = null, $messages = [])
{
// A request may be passed in when using Laravel traits, like how resetting
// passwords work. Get the input from it
if (is_a($data, \Illuminate\Http\Request::class)) {
$data = $data->input();
}
... | [
"protected",
"function",
"validate",
"(",
"$",
"data",
",",
"$",
"rules",
"=",
"null",
",",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"// A request may be passed in when using Laravel traits, like how resetting",
"// passwords work. Get the input from it",
"if",
"(",
"... | All actions validate in basically the same way. This is shared logic for that
@param BaseModel|Request|array $data
@param array $rules A Laravel rules array. If null, will be pulled from model
@param array $messages Special error messages
@return void
@throws ValidationFail | [
"All",
"actions",
"validate",
"in",
"basically",
"the",
"same",
"way",
".",
"This",
"is",
"shared",
"logic",
"for",
"that"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L893-L932 |
30,653 | BKWLD/decoy | classes/Controllers/Base.php | Base.formatAutocompleteResponse | public function formatAutocompleteResponse($results)
{
$output = [];
foreach ($results as $row) {
// Only keep the id and title fields
$item = new stdClass;
$item->id = $row->getKey();
$item->title = $row->getAdminTitleAttribute();
// Add... | php | public function formatAutocompleteResponse($results)
{
$output = [];
foreach ($results as $row) {
// Only keep the id and title fields
$item = new stdClass;
$item->id = $row->getKey();
$item->title = $row->getAdminTitleAttribute();
// Add... | [
"public",
"function",
"formatAutocompleteResponse",
"(",
"$",
"results",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"row",
")",
"{",
"// Only keep the id and title fields",
"$",
"item",
"=",
"new",
"stdClass",
";"... | Format the results of a query in the format needed for the autocomplete
responses
@param array $results
@return array | [
"Format",
"the",
"results",
"of",
"a",
"query",
"in",
"the",
"format",
"needed",
"for",
"the",
"autocomplete",
"responses"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L941-L974 |
30,654 | BKWLD/decoy | classes/Controllers/Base.php | Base.parentRelation | private function parentRelation()
{
if ($this->parent && method_exists($this->parent, $this->parent_to_self)) {
return $this->parent->{$this->parent_to_self}();
}
return false;
} | php | private function parentRelation()
{
if ($this->parent && method_exists($this->parent, $this->parent_to_self)) {
return $this->parent->{$this->parent_to_self}();
}
return false;
} | [
"private",
"function",
"parentRelation",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"&&",
"method_exists",
"(",
"$",
"this",
"->",
"parent",
",",
"$",
"this",
"->",
"parent_to_self",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parent",
"->... | Run the parent relationship function for the active model, returning the Relation
object. Returns false if none found.
@return Illuminate\Database\Eloquent\Relations\Relation | false | [
"Run",
"the",
"parent",
"relationship",
"function",
"for",
"the",
"active",
"model",
"returning",
"the",
"Relation",
"object",
".",
"Returns",
"false",
"if",
"none",
"found",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L993-L1000 |
30,655 | BKWLD/decoy | classes/Controllers/Base.php | Base.overrideViews | protected function overrideViews()
{
$dir = Str::snake($this->controllerName());
$path = base_path('resources/views/admin/').$dir;
app('view')->prependNamespace('decoy', $path);
} | php | protected function overrideViews()
{
$dir = Str::snake($this->controllerName());
$path = base_path('resources/views/admin/').$dir;
app('view')->prependNamespace('decoy', $path);
} | [
"protected",
"function",
"overrideViews",
"(",
")",
"{",
"$",
"dir",
"=",
"Str",
"::",
"snake",
"(",
"$",
"this",
"->",
"controllerName",
"(",
")",
")",
";",
"$",
"path",
"=",
"base_path",
"(",
"'resources/views/admin/'",
")",
".",
"$",
"dir",
";",
"ap... | Tell Laravel to look for view files within the app admin views so that,
on a controller-level basis, the app can customize elements of an admin
view through it's partials.
@return void | [
"Tell",
"Laravel",
"to",
"look",
"for",
"view",
"files",
"within",
"the",
"app",
"admin",
"views",
"so",
"that",
"on",
"a",
"controller",
"-",
"level",
"basis",
"the",
"app",
"can",
"customize",
"elements",
"of",
"an",
"admin",
"view",
"through",
"it",
"... | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L1009-L1014 |
30,656 | BKWLD/decoy | classes/Controllers/Base.php | Base.populateView | protected function populateView($content, $vars = [])
{
// The view
if (is_string($content)) {
$this->layout->content = View::make($content);
} else {
$this->layout->content = $content;
}
// Set vars
$this->layout->title = $this->title();
... | php | protected function populateView($content, $vars = [])
{
// The view
if (is_string($content)) {
$this->layout->content = View::make($content);
} else {
$this->layout->content = $content;
}
// Set vars
$this->layout->title = $this->title();
... | [
"protected",
"function",
"populateView",
"(",
"$",
"content",
",",
"$",
"vars",
"=",
"[",
"]",
")",
"{",
"// The view",
"if",
"(",
"is_string",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"layout",
"->",
"content",
"=",
"View",
"::",
"make... | Pass controller properties that are used by the layout and views through
to the view layer
@param mixed $content string view name or an HtmlObject / View object
@param array $vars Key value pairs passed to the content view
@return Illuminate\View\View | [
"Pass",
"controller",
"properties",
"that",
"are",
"used",
"by",
"the",
"layout",
"and",
"views",
"through",
"to",
"the",
"view",
"layer"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L1024-L1047 |
30,657 | BKWLD/decoy | classes/Controllers/Base.php | Base.successMessage | protected function successMessage($input = '', $verb = 'saved')
{
// Figure out the title and wrap it in quotes
$title = $input;
if (is_a($input, '\Bkwld\Decoy\Models\Base')) {
$title = $input->getAdminTitleAttribute();
}
if ($title && is_string($title)) {
... | php | protected function successMessage($input = '', $verb = 'saved')
{
// Figure out the title and wrap it in quotes
$title = $input;
if (is_a($input, '\Bkwld\Decoy\Models\Base')) {
$title = $input->getAdminTitleAttribute();
}
if ($title && is_string($title)) {
... | [
"protected",
"function",
"successMessage",
"(",
"$",
"input",
"=",
"''",
",",
"$",
"verb",
"=",
"'saved'",
")",
"{",
"// Figure out the title and wrap it in quotes",
"$",
"title",
"=",
"$",
"input",
";",
"if",
"(",
"is_a",
"(",
"$",
"input",
",",
"'\\Bkwld\\... | Creates a success message for CRUD commands
@param Bkwld\Decoy\Model\Base|string $title The model instance that is
being worked on or a string
containing the title
@param string $verb Default: 'saved'. Past tense CRUD verb (created, saved, etc)
@return string The CRUD ... | [
"Creates",
"a",
"success",
"message",
"for",
"CRUD",
"commands"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Base.php#L1058-L1086 |
30,658 | BKWLD/decoy | classes/Models/Traits/CanSerializeTransform.php | CanSerializeTransform.runSerializeTransforms | public function runSerializeTransforms()
{
// If the class using this trait is a collection, replace the items in the
// collection with the transformed set
if (is_a($this, Collection::class)) {
$this->items = $this->runSerializeTransformsOnCollection($this);
// Otherwis... | php | public function runSerializeTransforms()
{
// If the class using this trait is a collection, replace the items in the
// collection with the transformed set
if (is_a($this, Collection::class)) {
$this->items = $this->runSerializeTransformsOnCollection($this);
// Otherwis... | [
"public",
"function",
"runSerializeTransforms",
"(",
")",
"{",
"// If the class using this trait is a collection, replace the items in the",
"// collection with the transformed set",
"if",
"(",
"is_a",
"(",
"$",
"this",
",",
"Collection",
"::",
"class",
")",
")",
"{",
"$",
... | Apply all registered transforms to the items in the collection. If a
transform returns falsey, that model will be removed from the collection
@return void | [
"Apply",
"all",
"registered",
"transforms",
"to",
"the",
"items",
"in",
"the",
"collection",
".",
"If",
"a",
"transform",
"returns",
"falsey",
"that",
"model",
"will",
"be",
"removed",
"from",
"the",
"collection"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/CanSerializeTransform.php#L72-L83 |
30,659 | BKWLD/decoy | classes/Models/Traits/CanSerializeTransform.php | CanSerializeTransform.runSerializeTransformsOnCollection | protected function runSerializeTransformsOnCollection(Collection $collection)
{
// Loop through the collection and transform each model
return $collection->map(function ($item) {
// If collection item isn't a model, don't do anything
if (!is_a($item, Model::class)) return $i... | php | protected function runSerializeTransformsOnCollection(Collection $collection)
{
// Loop through the collection and transform each model
return $collection->map(function ($item) {
// If collection item isn't a model, don't do anything
if (!is_a($item, Model::class)) return $i... | [
"protected",
"function",
"runSerializeTransformsOnCollection",
"(",
"Collection",
"$",
"collection",
")",
"{",
"// Loop through the collection and transform each model",
"return",
"$",
"collection",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"// If collecti... | Run transforms on every model in a collection
@return Collection | [
"Run",
"transforms",
"on",
"every",
"model",
"in",
"a",
"collection"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/CanSerializeTransform.php#L90-L104 |
30,660 | BKWLD/decoy | classes/Models/Traits/CanSerializeTransform.php | CanSerializeTransform.runSerializeTransformsOnModel | protected function runSerializeTransformsOnModel(Model $model)
{
// Loop through all the transform functions
foreach ($this->serialize_transforms as $transform) {
// Call the transform and if nothing is retuned, return nothing. This will
// be used by runSerializeTransformsO... | php | protected function runSerializeTransformsOnModel(Model $model)
{
// Loop through all the transform functions
foreach ($this->serialize_transforms as $transform) {
// Call the transform and if nothing is retuned, return nothing. This will
// be used by runSerializeTransformsO... | [
"protected",
"function",
"runSerializeTransformsOnModel",
"(",
"Model",
"$",
"model",
")",
"{",
"// Loop through all the transform functions",
"foreach",
"(",
"$",
"this",
"->",
"serialize_transforms",
"as",
"$",
"transform",
")",
"{",
"// Call the transform and if nothing ... | Run transforms on a single model
@param Model $model
@return Model|void | [
"Run",
"transforms",
"on",
"a",
"single",
"model"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/CanSerializeTransform.php#L112-L126 |
30,661 | BKWLD/decoy | classes/Fields/Traits/CaptureLabel.php | CaptureLabel.label | public function label($text, $attributes = [])
{
$this->label_text = $text;
return parent::label($text, $attributes);
} | php | public function label($text, $attributes = [])
{
$this->label_text = $text;
return parent::label($text, $attributes);
} | [
"public",
"function",
"label",
"(",
"$",
"text",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"label_text",
"=",
"$",
"text",
";",
"return",
"parent",
"::",
"label",
"(",
"$",
"text",
",",
"$",
"attributes",
")",
";",
"}"
] | Override the parent label so we can use the raw text of the label
@param string $text A label
@param array $attributes The label's attributes
@return Field A field | [
"Override",
"the",
"parent",
"label",
"so",
"we",
"can",
"use",
"the",
"raw",
"text",
"of",
"the",
"label"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Traits/CaptureLabel.php#L25-L30 |
30,662 | BKWLD/decoy | classes/Controllers/ForgotPassword.php | ForgotPassword.showLinkRequestForm | public function showLinkRequestForm()
{
// Pass validation rules
Former::withRules([
'email' => 'required|email',
]);
// Set the breadcrumbs
app('decoy.breadcrumbs')->set([
route('decoy::account@login') => 'Login',
url()->current() => 'For... | php | public function showLinkRequestForm()
{
// Pass validation rules
Former::withRules([
'email' => 'required|email',
]);
// Set the breadcrumbs
app('decoy.breadcrumbs')->set([
route('decoy::account@login') => 'Login',
url()->current() => 'For... | [
"public",
"function",
"showLinkRequestForm",
"(",
")",
"{",
"// Pass validation rules",
"Former",
"::",
"withRules",
"(",
"[",
"'email'",
"=>",
"'required|email'",
",",
"]",
")",
";",
"// Set the breadcrumbs",
"app",
"(",
"'decoy.breadcrumbs'",
")",
"->",
"set",
"... | Display the form to request a password reset link.
@return \Illuminate\Http\Response | [
"Display",
"the",
"form",
"to",
"request",
"a",
"password",
"reset",
"link",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/ForgotPassword.php#L23-L41 |
30,663 | BKWLD/decoy | classes/Fields/Checklist.php | Checklist.from | public function from(array $options)
{
// Makes the options passed in override anything from the populator.
$this->grouped = true;
// Produce Former-style checkbox options
$options = FormerUtils::checkboxArray($this->name, $options);
$this->checkboxes($options);
// ... | php | public function from(array $options)
{
// Makes the options passed in override anything from the populator.
$this->grouped = true;
// Produce Former-style checkbox options
$options = FormerUtils::checkboxArray($this->name, $options);
$this->checkboxes($options);
// ... | [
"public",
"function",
"from",
"(",
"array",
"$",
"options",
")",
"{",
"// Makes the options passed in override anything from the populator.",
"$",
"this",
"->",
"grouped",
"=",
"true",
";",
"// Produce Former-style checkbox options",
"$",
"options",
"=",
"FormerUtils",
":... | Accept checkbox configuration from an associative array
@param array $options
@return $this | [
"Accept",
"checkbox",
"configuration",
"from",
"an",
"associative",
"array"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Checklist.php#L40-L51 |
30,664 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.index | public function index($locale = null, $tab = null)
{
// If there are no locales, treat the first argument as the tab
if (!($locales = Config::get('decoy.site.locales')) || empty($locales)) {
$tab = $locale;
$locale = null;
// Otherwise, set a default locale if none w... | php | public function index($locale = null, $tab = null)
{
// If there are no locales, treat the first argument as the tab
if (!($locales = Config::get('decoy.site.locales')) || empty($locales)) {
$tab = $locale;
$locale = null;
// Otherwise, set a default locale if none w... | [
"public",
"function",
"index",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"tab",
"=",
"null",
")",
"{",
"// If there are no locales, treat the first argument as the tab",
"if",
"(",
"!",
"(",
"$",
"locales",
"=",
"Config",
"::",
"get",
"(",
"'decoy.site.locales'... | All elements view
@param string $locale The locale to load from the DB
@param string $tab A deep link to a specific tab. Will get processed by JS
@return Illuminate\Http\Response | [
"All",
"elements",
"view"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L42-L91 |
30,665 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.renderField | public static function renderField($el, $key = null)
{
if (!$key) {
$key = $el->inputName();
}
$id = str_replace('|', '-', $key);
switch ($el->type) {
case 'text':
return Former::text($key, $el->label)
->blockHelp($el->hel... | php | public static function renderField($el, $key = null)
{
if (!$key) {
$key = $el->inputName();
}
$id = str_replace('|', '-', $key);
switch ($el->type) {
case 'text':
return Former::text($key, $el->label)
->blockHelp($el->hel... | [
"public",
"static",
"function",
"renderField",
"(",
"$",
"el",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"el",
"->",
"inputName",
"(",
")",
";",
"}",
"$",
"id",
"=",
"str_replace",
"(",
... | A helper function for rendering the list of fields
@param Bkwld\Decoy\Models\Element $el
@param string $key
@return Former\Traits\Object | [
"A",
"helper",
"function",
"for",
"rendering",
"the",
"list",
"of",
"fields"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L100-L177 |
30,666 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.store | public function store($locale = null)
{
// Get the default locale
if (!$locale) {
$locale = Decoy::defaultLocale();
}
// Hydrate the elements collection
$elements = app('decoy.elements')
->localize($locale)
->hydrate(true);
// If ... | php | public function store($locale = null)
{
// Get the default locale
if (!$locale) {
$locale = Decoy::defaultLocale();
}
// Hydrate the elements collection
$elements = app('decoy.elements')
->localize($locale)
->hydrate(true);
// If ... | [
"public",
"function",
"store",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"// Get the default locale",
"if",
"(",
"!",
"$",
"locale",
")",
"{",
"$",
"locale",
"=",
"Decoy",
"::",
"defaultLocale",
"(",
")",
";",
"}",
"// Hydrate the elements collection",
"$",... | Handle form post
@param string $locale The locale to assign to it
@return Illuminate\Http\Response | [
"Handle",
"form",
"post"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L185-L276 |
30,667 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.storeImage | protected function storeImage(Element $el, $input)
{
// Do nothing if no images
if (!is_array($input['images'])) {
return;
}
// Check for the image in the input. If isn't found, make no changes.
$name = $el->inputName();
if (!$data = array_first($input['... | php | protected function storeImage(Element $el, $input)
{
// Do nothing if no images
if (!is_array($input['images'])) {
return;
}
// Check for the image in the input. If isn't found, make no changes.
$name = $el->inputName();
if (!$data = array_first($input['... | [
"protected",
"function",
"storeImage",
"(",
"Element",
"$",
"el",
",",
"$",
"input",
")",
"{",
"// Do nothing if no images",
"if",
"(",
"!",
"is_array",
"(",
"$",
"input",
"[",
"'images'",
"]",
")",
")",
"{",
"return",
";",
"}",
"// Check for the image in th... | Handle storage of image Element types
@param Element $el
@param array $input
@return void | [
"Handle",
"storage",
"of",
"image",
"Element",
"types"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L285-L320 |
30,668 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.field | public function field($key)
{
return View::make('decoy::layouts.blank')
->nest('content', 'decoy::elements.field', [
'element' => app('decoy.elements')
->localize(Decoy::locale())
->hydrate(true)
->get($key),
... | php | public function field($key)
{
return View::make('decoy::layouts.blank')
->nest('content', 'decoy::elements.field', [
'element' => app('decoy.elements')
->localize(Decoy::locale())
->hydrate(true)
->get($key),
... | [
"public",
"function",
"field",
"(",
"$",
"key",
")",
"{",
"return",
"View",
"::",
"make",
"(",
"'decoy::layouts.blank'",
")",
"->",
"nest",
"(",
"'content'",
",",
"'decoy::elements.field'",
",",
"[",
"'element'",
"=>",
"app",
"(",
"'decoy.elements'",
")",
"-... | Show the field editor form that will appear in an iframe on
the frontend
@param string $key A full Element key
@return Illuminate\Http\Response | [
"Show",
"the",
"field",
"editor",
"form",
"that",
"will",
"appear",
"in",
"an",
"iframe",
"on",
"the",
"frontend"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L329-L338 |
30,669 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.fieldUpdate | public function fieldUpdate($key)
{
$elements = app('decoy.elements')->localize(Decoy::locale());
// If the value has changed, update or an insert a record in the database.
$el = Decoy::el($key);
$value = request('value');
if ($value != $el->value || Request::hasFile('value'... | php | public function fieldUpdate($key)
{
$elements = app('decoy.elements')->localize(Decoy::locale());
// If the value has changed, update or an insert a record in the database.
$el = Decoy::el($key);
$value = request('value');
if ($value != $el->value || Request::hasFile('value'... | [
"public",
"function",
"fieldUpdate",
"(",
"$",
"key",
")",
"{",
"$",
"elements",
"=",
"app",
"(",
"'decoy.elements'",
")",
"->",
"localize",
"(",
"Decoy",
"::",
"locale",
"(",
")",
")",
";",
"// If the value has changed, update or an insert a record in the database.... | Update a single field because of a frontend Element editor
iframe post
@param string $key A full Element key
@return Illuminate\Http\Response | [
"Update",
"a",
"single",
"field",
"because",
"of",
"a",
"frontend",
"Element",
"editor",
"iframe",
"post"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L347-L374 |
30,670 | BKWLD/decoy | classes/Controllers/Elements.php | Elements.getPermissionOptions | public function getPermissionOptions()
{
// Get all the grouped elements
$elements = app('decoy.elements')
->localize(Decoy::locale())
->hydrate(true)
->asModels()
->sortBy('page_label')
->groupBy('page_label');
// Map to the expec... | php | public function getPermissionOptions()
{
// Get all the grouped elements
$elements = app('decoy.elements')
->localize(Decoy::locale())
->hydrate(true)
->asModels()
->sortBy('page_label')
->groupBy('page_label');
// Map to the expec... | [
"public",
"function",
"getPermissionOptions",
"(",
")",
"{",
"// Get all the grouped elements",
"$",
"elements",
"=",
"app",
"(",
"'decoy.elements'",
")",
"->",
"localize",
"(",
"Decoy",
"::",
"locale",
"(",
")",
")",
"->",
"hydrate",
"(",
"true",
")",
"->",
... | The permissions options are a list of all the tabs
@return array | [
"The",
"permissions",
"options",
"are",
"a",
"list",
"of",
"all",
"the",
"tabs"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Elements.php#L381-L398 |
30,671 | BKWLD/decoy | classes/Helpers.php | Helpers.title | public function title()
{
// If no title has been set, try to figure it out based on breadcrumbs
$title = View::yieldContent('title');
if (empty($title)) {
$title = app('decoy.breadcrumbs')->title();
}
// Set the title
$site = $this->site();
retu... | php | public function title()
{
// If no title has been set, try to figure it out based on breadcrumbs
$title = View::yieldContent('title');
if (empty($title)) {
$title = app('decoy.breadcrumbs')->title();
}
// Set the title
$site = $this->site();
retu... | [
"public",
"function",
"title",
"(",
")",
"{",
"// If no title has been set, try to figure it out based on breadcrumbs",
"$",
"title",
"=",
"View",
"::",
"yieldContent",
"(",
"'title'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",... | Generate title tags based on section content
@return string | [
"Generate",
"title",
"tags",
"based",
"on",
"section",
"content"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L32-L44 |
30,672 | BKWLD/decoy | classes/Helpers.php | Helpers.site | public function site()
{
$site = Config::get('decoy.site.name');
if (is_callable($site)) {
$site = call_user_func($site);
}
return $site;
} | php | public function site()
{
$site = Config::get('decoy.site.name');
if (is_callable($site)) {
$site = call_user_func($site);
}
return $site;
} | [
"public",
"function",
"site",
"(",
")",
"{",
"$",
"site",
"=",
"Config",
"::",
"get",
"(",
"'decoy.site.name'",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"site",
")",
")",
"{",
"$",
"site",
"=",
"call_user_func",
"(",
"$",
"site",
")",
";",
"}"... | Get the site name
@return string | [
"Get",
"the",
"site",
"name"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L51-L59 |
30,673 | BKWLD/decoy | classes/Helpers.php | Helpers.bodyClass | public function bodyClass()
{
$path = Request::path();
$classes = [];
// Special condition for the elements
if (strpos($path, '/elements/field/') !== false) {
return 'elements field';
}
// Special condition for the reset page, which passes the token in a... | php | public function bodyClass()
{
$path = Request::path();
$classes = [];
// Special condition for the elements
if (strpos($path, '/elements/field/') !== false) {
return 'elements field';
}
// Special condition for the reset page, which passes the token in a... | [
"public",
"function",
"bodyClass",
"(",
")",
"{",
"$",
"path",
"=",
"Request",
"::",
"path",
"(",
")",
";",
"$",
"classes",
"=",
"[",
"]",
";",
"// Special condition for the elements",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'/elements/field/'",
")",
... | Add the controller and action as CSS classes on the body tag | [
"Add",
"the",
"controller",
"and",
"action",
"as",
"CSS",
"classes",
"on",
"the",
"body",
"tag"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L64-L98 |
30,674 | BKWLD/decoy | classes/Helpers.php | Helpers.els | public function els($prefix, $crops = [])
{
return app('decoy.elements')
->localize($this->locale())
->getMany($prefix, $crops);
} | php | public function els($prefix, $crops = [])
{
return app('decoy.elements')
->localize($this->locale())
->getMany($prefix, $crops);
} | [
"public",
"function",
"els",
"(",
"$",
"prefix",
",",
"$",
"crops",
"=",
"[",
"]",
")",
"{",
"return",
"app",
"(",
"'decoy.elements'",
")",
"->",
"localize",
"(",
"$",
"this",
"->",
"locale",
"(",
")",
")",
"->",
"getMany",
"(",
"$",
"prefix",
",",... | Return a number of Element values at once in an associative array
@param string $prefix Any leading part of a key
@param array $crops Assoc array with Element partial keys for ITS keys
and values as an arary of crop()-style arguments
@return array | [
"Return",
"a",
"number",
"of",
"Element",
"values",
"at",
"once",
"in",
"an",
"associative",
"array"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L221-L226 |
30,675 | BKWLD/decoy | classes/Helpers.php | Helpers.defaultLocale | public function defaultLocale()
{
if (($locales = Config::get('decoy.site.locales'))
&& is_array($locales)) {
reset($locales);
return key($locales);
}
} | php | public function defaultLocale()
{
if (($locales = Config::get('decoy.site.locales'))
&& is_array($locales)) {
reset($locales);
return key($locales);
}
} | [
"public",
"function",
"defaultLocale",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"locales",
"=",
"Config",
"::",
"get",
"(",
"'decoy.site.locales'",
")",
")",
"&&",
"is_array",
"(",
"$",
"locales",
")",
")",
"{",
"reset",
"(",
"$",
"locales",
")",
";",
"re... | Get the default locale, aka, the first locales array key
@return string | [
"Get",
"the",
"default",
"locale",
"aka",
"the",
"first",
"locales",
"array",
"key"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L304-L312 |
30,676 | BKWLD/decoy | classes/Helpers.php | Helpers.modelForController | public function modelForController($controller)
{
// Swap out the namespace if decoy
$model = str_replace('Bkwld\Decoy\Controllers',
'Bkwld\Decoy\Models',
$controller,
$is_decoy);
// Replace non-decoy controller's with the standard model namespace
... | php | public function modelForController($controller)
{
// Swap out the namespace if decoy
$model = str_replace('Bkwld\Decoy\Controllers',
'Bkwld\Decoy\Models',
$controller,
$is_decoy);
// Replace non-decoy controller's with the standard model namespace
... | [
"public",
"function",
"modelForController",
"(",
"$",
"controller",
")",
"{",
"// Swap out the namespace if decoy",
"$",
"model",
"=",
"str_replace",
"(",
"'Bkwld\\Decoy\\Controllers'",
",",
"'Bkwld\\Decoy\\Models'",
",",
"$",
"controller",
",",
"$",
"is_decoy",
")",
... | Get the model class string from a controller class string
@param string $controller ex: "App\Http\Controllers\Admin\People"
@return string ex: "App\Person" | [
"Get",
"the",
"model",
"class",
"string",
"from",
"a",
"controller",
"class",
"string"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L320-L338 |
30,677 | BKWLD/decoy | classes/Helpers.php | Helpers.controllerForModel | public function controllerForModel($model)
{
// Swap out the namespace if decoy
$controller = str_replace('Bkwld\Decoy\Models', 'Bkwld\Decoy\Controllers', $model, $is_decoy);
// Replace non-decoy controller's with the standard model namespace
if (!$is_decoy) {
$namespace... | php | public function controllerForModel($model)
{
// Swap out the namespace if decoy
$controller = str_replace('Bkwld\Decoy\Models', 'Bkwld\Decoy\Controllers', $model, $is_decoy);
// Replace non-decoy controller's with the standard model namespace
if (!$is_decoy) {
$namespace... | [
"public",
"function",
"controllerForModel",
"(",
"$",
"model",
")",
"{",
"// Swap out the namespace if decoy",
"$",
"controller",
"=",
"str_replace",
"(",
"'Bkwld\\Decoy\\Models'",
",",
"'Bkwld\\Decoy\\Controllers'",
",",
"$",
"model",
",",
"$",
"is_decoy",
")",
";",
... | Get the controller class string from a model class string
@param string $controller ex: "App\Person"
@return string ex: "App\Http\Controllers\Admin\People" | [
"Get",
"the",
"controller",
"class",
"string",
"from",
"a",
"model",
"class",
"string"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L346-L360 |
30,678 | BKWLD/decoy | classes/Helpers.php | Helpers.filteredInput | public function filteredInput()
{
$files = $this->arrayFilterRecursive(Request::file());
$input = array_replace_recursive(Request::input(), $files);
return Library\Utils\Collection::nullEmpties($input);
} | php | public function filteredInput()
{
$files = $this->arrayFilterRecursive(Request::file());
$input = array_replace_recursive(Request::input(), $files);
return Library\Utils\Collection::nullEmpties($input);
} | [
"public",
"function",
"filteredInput",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"arrayFilterRecursive",
"(",
"Request",
"::",
"file",
"(",
")",
")",
";",
"$",
"input",
"=",
"array_replace_recursive",
"(",
"Request",
"::",
"input",
"(",
")",
"... | Get all input but filter out empty file fields. This prevents empty file
fields from overriding existing files on a model. Using this assumes that
we are filling a model and then validating the model attributes.
@return array | [
"Get",
"all",
"input",
"but",
"filter",
"out",
"empty",
"file",
"fields",
".",
"This",
"prevents",
"empty",
"file",
"fields",
"from",
"overriding",
"existing",
"files",
"on",
"a",
"model",
".",
"Using",
"this",
"assumes",
"that",
"we",
"are",
"filling",
"a... | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Helpers.php#L393-L399 |
30,679 | BKWLD/decoy | classes/Observers/ModelCallbacks.php | ModelCallbacks.handle | public function handle($event, $payload)
{
list($model) = $payload;
// Get the action from the event name
preg_match('#\.(\w+)#', $event, $matches);
$action = $matches[1];
// If there is matching callback method on the model, call it, passing
// any additional event... | php | public function handle($event, $payload)
{
list($model) = $payload;
// Get the action from the event name
preg_match('#\.(\w+)#', $event, $matches);
$action = $matches[1];
// If there is matching callback method on the model, call it, passing
// any additional event... | [
"public",
"function",
"handle",
"(",
"$",
"event",
",",
"$",
"payload",
")",
"{",
"list",
"(",
"$",
"model",
")",
"=",
"$",
"payload",
";",
"// Get the action from the event name",
"preg_match",
"(",
"'#\\.(\\w+)#'",
",",
"$",
"event",
",",
"$",
"matches",
... | Handle all model events, both Eloquent and Decoy
@param string $event
@param array $payload Contains:
- Bkwld\Decoy\Models\Base $model
@return void | [
"Handle",
"all",
"model",
"events",
"both",
"Eloquent",
"and",
"Decoy"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Observers/ModelCallbacks.php#L22-L36 |
30,680 | BKWLD/decoy | classes/Models/Element.php | Element.setAttribute | public function setAttribute($key, $value)
{
if ($key == 'type') {
switch ($value) {
case 'image': self::$rules['value'] = 'image';
break;
case 'file': self::$rules['value'] = 'file';
break;
case 'video-encoder': self::$rules['value'] =... | php | public function setAttribute($key, $value)
{
if ($key == 'type') {
switch ($value) {
case 'image': self::$rules['value'] = 'image';
break;
case 'file': self::$rules['value'] = 'file';
break;
case 'video-encoder': self::$rules['value'] =... | [
"public",
"function",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'type'",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'image'",
":",
"self",
"::",
"$",
"rules",
"[",
"'value'",
"]",
"... | Subclass setAttribute so that we can automatically set validation
rules based on the Element type
@param string $key
@param mixed $value
@return void | [
"Subclass",
"setAttribute",
"so",
"that",
"we",
"can",
"automatically",
"set",
"validation",
"rules",
"based",
"on",
"the",
"Element",
"type"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L103-L118 |
30,681 | BKWLD/decoy | classes/Models/Element.php | Element.value | public function value()
{
// Must return a string
if (empty($this->value)) {
return '';
}
// Different outputs depending on type
switch ($this->type) {
case 'boolean': return !empty($this->value);
case 'image': return $this->img()->url;
... | php | public function value()
{
// Must return a string
if (empty($this->value)) {
return '';
}
// Different outputs depending on type
switch ($this->type) {
case 'boolean': return !empty($this->value);
case 'image': return $this->img()->url;
... | [
"public",
"function",
"value",
"(",
")",
"{",
"// Must return a string",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Different outputs depending on type",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
... | Format the value before returning it based on the type
@return mixed Stringable | [
"Format",
"the",
"value",
"before",
"returning",
"it",
"based",
"on",
"the",
"type"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L125-L144 |
30,682 | BKWLD/decoy | classes/Models/Element.php | Element.relatedModel | protected function relatedModel()
{
$yaml = app('decoy.elements')->getConfig();
$model = array_get($yaml, $this->key.'.class')
?: array_get($yaml, $this->key.',model.class');
return $model::find($this->value);
} | php | protected function relatedModel()
{
$yaml = app('decoy.elements')->getConfig();
$model = array_get($yaml, $this->key.'.class')
?: array_get($yaml, $this->key.',model.class');
return $model::find($this->value);
} | [
"protected",
"function",
"relatedModel",
"(",
")",
"{",
"$",
"yaml",
"=",
"app",
"(",
"'decoy.elements'",
")",
"->",
"getConfig",
"(",
")",
";",
"$",
"model",
"=",
"array_get",
"(",
"$",
"yaml",
",",
"$",
"this",
"->",
"key",
".",
"'.class'",
")",
"?... | Get the model referenced in a "model" field
@return Model | [
"Get",
"the",
"model",
"referenced",
"in",
"a",
"model",
"field"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L151-L158 |
30,683 | BKWLD/decoy | classes/Models/Element.php | Element.img | public function img()
{
// Check for an existing Image relation
if (($image = $this->parentImg($this->inputName()))
&& $image->exists) {
// If the Image represents a default image, but doesn't match the current
// item from the config, trash the current one and b... | php | public function img()
{
// Check for an existing Image relation
if (($image = $this->parentImg($this->inputName()))
&& $image->exists) {
// If the Image represents a default image, but doesn't match the current
// item from the config, trash the current one and b... | [
"public",
"function",
"img",
"(",
")",
"{",
"// Check for an existing Image relation",
"if",
"(",
"(",
"$",
"image",
"=",
"$",
"this",
"->",
"parentImg",
"(",
"$",
"this",
"->",
"inputName",
"(",
")",
")",
")",
"&&",
"$",
"image",
"->",
"exists",
")",
... | Look for default iamges using a named key. It was a lot simpler in the
integeration with the Elements admin UI to store the input name in the
"name" attribute
@return Image | [
"Look",
"for",
"default",
"iamges",
"using",
"a",
"named",
"key",
".",
"It",
"was",
"a",
"lot",
"simpler",
"in",
"the",
"integeration",
"with",
"the",
"Elements",
"admin",
"UI",
"to",
"store",
"the",
"input",
"name",
"in",
"the",
"name",
"attribute"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L189-L208 |
30,684 | BKWLD/decoy | classes/Models/Element.php | Element.getReplacementImage | protected function getReplacementImage(Image $image)
{
// Check that the image is in the elements dir, which means it's
// a default image
if (!strpos($image->file, '/elements/')) {
return;
}
// Get the current file value form the YAML. Need to check for the
... | php | protected function getReplacementImage(Image $image)
{
// Check that the image is in the elements dir, which means it's
// a default image
if (!strpos($image->file, '/elements/')) {
return;
}
// Get the current file value form the YAML. Need to check for the
... | [
"protected",
"function",
"getReplacementImage",
"(",
"Image",
"$",
"image",
")",
"{",
"// Check that the image is in the elements dir, which means it's",
"// a default image",
"if",
"(",
"!",
"strpos",
"(",
"$",
"image",
"->",
"file",
",",
"'/elements/'",
")",
")",
"{... | Check if the Image represents a default image but is out of date
@param Image $image
@return Image|void | [
"Check",
"if",
"the",
"Image",
"represents",
"a",
"default",
"image",
"but",
"is",
"out",
"of",
"date"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L216-L242 |
30,685 | BKWLD/decoy | classes/Models/Element.php | Element.defaultImage | public function defaultImage()
{
// Return an empty Image object if no default value
if (empty($this->value)) {
return new Image;
}
// All src images must live in the /img (relative) directory
if (!Str::is('/img/*', $this->value)) {
$msg = 'Element im... | php | public function defaultImage()
{
// Return an empty Image object if no default value
if (empty($this->value)) {
return new Image;
}
// All src images must live in the /img (relative) directory
if (!Str::is('/img/*', $this->value)) {
$msg = 'Element im... | [
"public",
"function",
"defaultImage",
"(",
")",
"{",
"// Return an empty Image object if no default value",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"return",
"new",
"Image",
";",
"}",
"// All src images must live in the /img (relative) direct... | Check if the value looks like an image. If it does, copy it to the uploads
dir so Croppa can work on it and return the modified path
@return Image | [
"Check",
"if",
"the",
"value",
"looks",
"like",
"an",
"image",
".",
"If",
"it",
"does",
"copy",
"it",
"to",
"the",
"uploads",
"dir",
"so",
"Croppa",
"can",
"work",
"on",
"it",
"and",
"return",
"the",
"modified",
"path"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Element.php#L250-L302 |
30,686 | BKWLD/decoy | classes/Collections/Elements.php | Elements.asModels | public function asModels()
{
$this->hydrate();
return new ModelCollection(array_map(function ($element, $key) {
// Add the key as an attribute
return new $this->model(array_merge($element, ['key' => $key]));
}, $this->all(), array_keys($this->items)));
} | php | public function asModels()
{
$this->hydrate();
return new ModelCollection(array_map(function ($element, $key) {
// Add the key as an attribute
return new $this->model(array_merge($element, ['key' => $key]));
}, $this->all(), array_keys($this->items)));
} | [
"public",
"function",
"asModels",
"(",
")",
"{",
"$",
"this",
"->",
"hydrate",
"(",
")",
";",
"return",
"new",
"ModelCollection",
"(",
"array_map",
"(",
"function",
"(",
"$",
"element",
",",
"$",
"key",
")",
"{",
"// Add the key as an attribute",
"return",
... | Map the items into a collection of Element instances
@return Bkwld\Decoy\Collections\Elements | [
"Map",
"the",
"items",
"into",
"a",
"collection",
"of",
"Element",
"instances"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L71-L80 |
30,687 | BKWLD/decoy | classes/Collections/Elements.php | Elements.get | public function get($key, $default = null)
{
$this->hydrate();
// Create an Element instance using the data for the key
if ($this->has($key)) {
return new $this->model(array_merge($this->items[$key], ['key' => $key]));
}
// If the key doesn't exist but a default... | php | public function get($key, $default = null)
{
$this->hydrate();
// Create an Element instance using the data for the key
if ($this->has($key)) {
return new $this->model(array_merge($this->items[$key], ['key' => $key]));
}
// If the key doesn't exist but a default... | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"hydrate",
"(",
")",
";",
"// Create an Element instance using the data for the key",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
... | Get an element given it's key
@param string $key
@return Bkwld\Decoy\Models\Element | [
"Get",
"an",
"element",
"given",
"it",
"s",
"key"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L88-L111 |
30,688 | BKWLD/decoy | classes/Collections/Elements.php | Elements.getMany | public function getMany($prefix, $crops = [])
{
// Get all of the elements matching the prefix with dot-notated keys
$dotted = $this
->hydrate()
->filter(function($val, $key) use ($prefix) {
return starts_with($key, $prefix);
// Loop through all m... | php | public function getMany($prefix, $crops = [])
{
// Get all of the elements matching the prefix with dot-notated keys
$dotted = $this
->hydrate()
->filter(function($val, $key) use ($prefix) {
return starts_with($key, $prefix);
// Loop through all m... | [
"public",
"function",
"getMany",
"(",
"$",
"prefix",
",",
"$",
"crops",
"=",
"[",
"]",
")",
"{",
"// Get all of the elements matching the prefix with dot-notated keys",
"$",
"dotted",
"=",
"$",
"this",
"->",
"hydrate",
"(",
")",
"->",
"filter",
"(",
"function",
... | Get a number of elements at once by passing in a first or second level
depth key. Like just `'homepage.marquee'`
@param string $prefix Any leading part of a key
@param array $crops Assoc array with Element partial keys for ITS keys
and values as an arary of crop()-style arguments
@return array | [
"Get",
"a",
"number",
"of",
"elements",
"at",
"once",
"by",
"passing",
"in",
"a",
"first",
"or",
"second",
"level",
"depth",
"key",
".",
"Like",
"just",
"homepage",
".",
"marquee"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L122-L167 |
30,689 | BKWLD/decoy | classes/Collections/Elements.php | Elements.mergeSources | protected function mergeSources()
{
$assoc = $this->assocConfig();
return array_replace_recursive($assoc,
// Get only the databse records whose keys are present in the YAML. This removes
// entries that may be from older YAML configs.
array_intersect_key($this-... | php | protected function mergeSources()
{
$assoc = $this->assocConfig();
return array_replace_recursive($assoc,
// Get only the databse records whose keys are present in the YAML. This removes
// entries that may be from older YAML configs.
array_intersect_key($this-... | [
"protected",
"function",
"mergeSources",
"(",
")",
"{",
"$",
"assoc",
"=",
"$",
"this",
"->",
"assocConfig",
"(",
")",
";",
"return",
"array_replace_recursive",
"(",
"$",
"assoc",
",",
"// Get only the databse records whose keys are present in the YAML. This removes",
... | Merge database records and config file into a single, flat associative array.
@return void | [
"Merge",
"database",
"records",
"and",
"config",
"file",
"into",
"a",
"single",
"flat",
"associative",
"array",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L280-L290 |
30,690 | BKWLD/decoy | classes/Collections/Elements.php | Elements.assocConfig | public function assocConfig($include_extra = false)
{
// Load the config data if it isn't already
if (!$this->config) {
$this->loadConfig();
}
// Loop through the YAML config and make flattened keys. The ternary
// operators in here allow a shorthand version of ... | php | public function assocConfig($include_extra = false)
{
// Load the config data if it isn't already
if (!$this->config) {
$this->loadConfig();
}
// Loop through the YAML config and make flattened keys. The ternary
// operators in here allow a shorthand version of ... | [
"public",
"function",
"assocConfig",
"(",
"$",
"include_extra",
"=",
"false",
")",
"{",
"// Load the config data if it isn't already",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
")",
"{",
"$",
"this",
"->",
"loadConfig",
"(",
")",
";",
"}",
"// Loop through ... | Massage the YAML config file into a single, flat associative array
@param boolean $include_extra Include attibutes that are only needed by Admin UIs
@return array | [
"Massage",
"the",
"YAML",
"config",
"file",
"into",
"a",
"single",
"flat",
"associative",
"array"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L298-L353 |
30,691 | BKWLD/decoy | classes/Collections/Elements.php | Elements.mergeExtra | protected function mergeExtra(&$el, $key, $data, $prefix = null)
{
// Don't add extra if this in the 1st or 2nd depth (which means there is a prefix)
// and there is no node for the children. This prevents a FIELD named "label" to be
// treated as the the label for it's section.
$sk... | php | protected function mergeExtra(&$el, $key, $data, $prefix = null)
{
// Don't add extra if this in the 1st or 2nd depth (which means there is a prefix)
// and there is no node for the children. This prevents a FIELD named "label" to be
// treated as the the label for it's section.
$sk... | [
"protected",
"function",
"mergeExtra",
"(",
"&",
"$",
"el",
",",
"$",
"key",
",",
"$",
"data",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"// Don't add extra if this in the 1st or 2nd depth (which means there is a prefix)",
"// and there is no node for the children. This p... | Add label and help to the element data for one of the levels
@param array $el The element data that is being merged into, passed by reference
@param mixed $data The data for a level in the Elements YAML config
@param string $prefix A prefix to append to the beginning of the key being set on $el | [
"Add",
"label",
"and",
"help",
"to",
"the",
"element",
"data",
"for",
"one",
"of",
"the",
"levels"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L362-L385 |
30,692 | BKWLD/decoy | classes/Collections/Elements.php | Elements.assocAdminChoices | protected function assocAdminChoices()
{
// Build the query
$query = call_user_func([$this->model, 'query']);
if ($this->locale) {
$query->localize($this->locale);
}
// Convert models to simple array
$elements = array_map(function (Element $element) {
... | php | protected function assocAdminChoices()
{
// Build the query
$query = call_user_func([$this->model, 'query']);
if ($this->locale) {
$query->localize($this->locale);
}
// Convert models to simple array
$elements = array_map(function (Element $element) {
... | [
"protected",
"function",
"assocAdminChoices",
"(",
")",
"{",
"// Build the query",
"$",
"query",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"model",
",",
"'query'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"locale",
")",
"{",
"$",
"query",
... | Get admin overrides to Elements from the databse
@return array | [
"Get",
"admin",
"overrides",
"to",
"Elements",
"from",
"the",
"databse"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L392-L420 |
30,693 | BKWLD/decoy | classes/Collections/Elements.php | Elements.loadConfig | protected function loadConfig()
{
// Start with empty config
$this->config = [];
// Build a lit of all the paths
$dir = config_path('decoy').'/';
$files = [];
if (is_readable($dir.'elements.yaml')) {
$files[] = $dir.'elements.yaml';
}
if (... | php | protected function loadConfig()
{
// Start with empty config
$this->config = [];
// Build a lit of all the paths
$dir = config_path('decoy').'/';
$files = [];
if (is_readable($dir.'elements.yaml')) {
$files[] = $dir.'elements.yaml';
}
if (... | [
"protected",
"function",
"loadConfig",
"(",
")",
"{",
"// Start with empty config",
"$",
"this",
"->",
"config",
"=",
"[",
"]",
";",
"// Build a lit of all the paths",
"$",
"dir",
"=",
"config_path",
"(",
"'decoy'",
")",
".",
"'/'",
";",
"$",
"files",
"=",
"... | Load the config file and store it internally
@return void | [
"Load",
"the",
"config",
"file",
"and",
"store",
"it",
"internally"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L441-L470 |
30,694 | BKWLD/decoy | classes/Collections/Elements.php | Elements.keyUpdated | public function keyUpdated($key)
{
if ($this->updated_items === null) {
$this->assocAdminChoices();
}
return in_array($key, $this->updated_items);
} | php | public function keyUpdated($key)
{
if ($this->updated_items === null) {
$this->assocAdminChoices();
}
return in_array($key, $this->updated_items);
} | [
"public",
"function",
"keyUpdated",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"updated_items",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"assocAdminChoices",
"(",
")",
";",
"}",
"return",
"in_array",
"(",
"$",
"key",
",",
"$",
"this"... | Check if a key has been stored in the database
@param string $key The key of an element
@return boolean | [
"Check",
"if",
"a",
"key",
"has",
"been",
"stored",
"in",
"the",
"database"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L478-L485 |
30,695 | BKWLD/decoy | classes/Collections/Elements.php | Elements.onlyPages | public function onlyPages($pages)
{
$this->items = array_filter($this->items, function ($element) use ($pages) {
return in_array(Str::slug($element['page_label']), $pages);
});
return $this;
} | php | public function onlyPages($pages)
{
$this->items = array_filter($this->items, function ($element) use ($pages) {
return in_array(Str::slug($element['page_label']), $pages);
});
return $this;
} | [
"public",
"function",
"onlyPages",
"(",
"$",
"pages",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"$",
"element",
")",
"use",
"(",
"$",
"pages",
")",
"{",
"return",
"in_array",
"("... | Filter the elements to only those allowed in the provided pages
@param array $pages
@return $this | [
"Filter",
"the",
"elements",
"to",
"only",
"those",
"allowed",
"in",
"the",
"provided",
"pages"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L493-L500 |
30,696 | BKWLD/decoy | classes/Collections/Elements.php | Elements.rules | public function rules()
{
$rules = [];
foreach ($this->assocConfig(true) as $key => $data) {
if (empty($data['rules'])) {
continue;
}
$rules[str_replace('.', '|', $key)] = $data['rules'];
}
return $rules;
} | php | public function rules()
{
$rules = [];
foreach ($this->assocConfig(true) as $key => $data) {
if (empty($data['rules'])) {
continue;
}
$rules[str_replace('.', '|', $key)] = $data['rules'];
}
return $rules;
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"assocConfig",
"(",
"true",
")",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'rule... | Return the validation rules for the items. Convert the keys to the
expected input style
@return array An array of validation rules, keyed to element keys | [
"Return",
"the",
"validation",
"rules",
"for",
"the",
"items",
".",
"Convert",
"the",
"keys",
"to",
"the",
"expected",
"input",
"style"
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L508-L519 |
30,697 | BKWLD/decoy | classes/Collections/Elements.php | Elements.populate | public function populate()
{
return array_combine(array_map(function ($key) {
return str_replace('.', '|', $key);
}, $this->keys()->all()), $this->pluck('value')->all());
} | php | public function populate()
{
return array_combine(array_map(function ($key) {
return str_replace('.', '|', $key);
}, $this->keys()->all()), $this->pluck('value')->all());
} | [
"public",
"function",
"populate",
"(",
")",
"{",
"return",
"array_combine",
"(",
"array_map",
"(",
"function",
"(",
"$",
"key",
")",
"{",
"return",
"str_replace",
"(",
"'.'",
",",
"'|'",
",",
"$",
"key",
")",
";",
"}",
",",
"$",
"this",
"->",
"keys",... | Return key-value pairs for use by former to populate the fields. The
keys must be converted to the Input safe variant.
@return array | [
"Return",
"key",
"-",
"value",
"pairs",
"for",
"use",
"by",
"former",
"to",
"populate",
"the",
"fields",
".",
"The",
"keys",
"must",
"be",
"converted",
"to",
"the",
"Input",
"safe",
"variant",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Collections/Elements.php#L527-L532 |
30,698 | BKWLD/decoy | classes/Fields/Upload.php | Upload.render | public function render()
{
// A file has already been uploaded
if ($this->value) {
// If it's required, show the icon but don't enforce it. There is already
// a file uploaded after all
if ($this->isRequired()) {
$this->setAttribute('required', n... | php | public function render()
{
// A file has already been uploaded
if ($this->value) {
// If it's required, show the icon but don't enforce it. There is already
// a file uploaded after all
if ($this->isRequired()) {
$this->setAttribute('required', n... | [
"public",
"function",
"render",
"(",
")",
"{",
"// A file has already been uploaded",
"if",
"(",
"$",
"this",
"->",
"value",
")",
"{",
"// If it's required, show the icon but don't enforce it. There is already",
"// a file uploaded after all",
"if",
"(",
"$",
"this",
"->",... | Prints out the current file upload field.
@return string An input tag | [
"Prints",
"out",
"the",
"current",
"file",
"upload",
"field",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Upload.php#L57-L71 |
30,699 | BKWLD/decoy | classes/Observers/ManyToManyChecklist.php | ManyToManyChecklist.handle | public function handle($event, $payload)
{
list($model) = $payload;
// Check for matching input elements
foreach (Request::input() as $key => $val) {
if (preg_match('#^'.self::PREFIX.'(.+)#', $key, $matches)) {
$this->updateRelationship($model, $matches[1... | php | public function handle($event, $payload)
{
list($model) = $payload;
// Check for matching input elements
foreach (Request::input() as $key => $val) {
if (preg_match('#^'.self::PREFIX.'(.+)#', $key, $matches)) {
$this->updateRelationship($model, $matches[1... | [
"public",
"function",
"handle",
"(",
"$",
"event",
",",
"$",
"payload",
")",
"{",
"list",
"(",
"$",
"model",
")",
"=",
"$",
"payload",
";",
"// Check for matching input elements",
"foreach",
"(",
"Request",
"::",
"input",
"(",
")",
"as",
"$",
"key",
"=>"... | Take input from a Many to Many Checklist and commit it to the db. Called
on model saved.
@param string $event
@param array $payload Contains:
- Bkwld\Decoy\Models\Base $model
@return void | [
"Take",
"input",
"from",
"a",
"Many",
"to",
"Many",
"Checklist",
"and",
"commit",
"it",
"to",
"the",
"db",
".",
"Called",
"on",
"model",
"saved",
"."
] | 7a4acfa8e00cdca7ef4d82672a6547bae61f8e73 | https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Observers/ManyToManyChecklist.php#L28-L38 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.