This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object(Cake\ORM\Query) { | |
'sql' => 'SELECT Roles.id AS `Roles__id`, Roles.parent_id AS `Roles__parent_id`, Roles.lft AS `Roles__lft`, Roles.rght AS `Roles__rght`, Roles.name AS `Roles__name`, Roles.description AS `Roles__description`, Roles.created AS `Roles__created`, Roles.updated AS `Roles__updated`, Parents.id AS `Parents__id`, Parents.parent_id AS `Parents__parent_id`, Parents.lft AS `Parents__lft`, Parents.rght AS `Parents__rght`, Parents.name AS `Parents__name`, Parents.description AS `Parents__description`, Parents.created AS `Parents__created`, Parents.updated AS `Parents__updated` FROM roles AS Roles LEFT JOIN roles Parents ON Parents.id = (Roles.parent_id)', | |
'params' => [], | |
'defaultTypes' => [ | |
'Roles.id' => 'integer', | |
'id' => 'integer', | |
'Roles.parent_id' => 'integer', | |
'parent_id' => 'integer', | |
'Roles.lft' => 'integer', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array (size=59) | |
0 => string 'initialize' (length=10) | |
1 => string 'validationDefault' (length=17) | |
2 => string 'initializeDb' (length=12) | |
3 => string '__construct' (length=11) | |
4 => string 'defaultConnectionName' (length=21) | |
5 => string 'table' (length=5) | |
6 => string 'alias' (length=5) | |
7 => string 'connection' (length=10) | |
8 => string 'schema' (length=6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/Model/Table/ResourcesTable.php | |
namespace App\Model\Table; | |
use Cake\ORM\Table; | |
use Cake\ORM\TableRegistry; | |
use Cake\Validation\Validator; | |
use ReflectionClass; | |
class ResourcesTable extends AppTable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function validationDefault(Validator $validator) { | |
return $validator | |
->validatePresence('role_id') | |
->notEmpty('role_id', 'A role is required') | |
->add('role_id', [ | |
'unique' => [ | |
'rule' => function($value, $context){ | |
//debug($context); | |
return $context['data']['isUnique']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This is my autocomplete widget | |
<?php | |
namespace App\View\Widget; | |
use Cake\View\Widget\WidgetInterface; | |
use Cake\View\Form\ContextInterface; | |
class Autocomplete implements WidgetInterface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Controller: | |
public function editPrestige($id=null){ | |
$prestigeLog = $this->PrestigeLogs->find() | |
->contain([ | |
'Members.Domains', | |
'PrestigeLogsItems'=> function ($q){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function editPrestige($id=null){ | |
$prestigeLog = $this->PrestigeLogs->get($id, | |
['contain'=>[ | |
'Members.Domains', | |
'PrestigeLogsItems'=> function ($q){ | |
return $q->where(['approved_id IS NULL']); | |
} | |
]]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From /cam-website/config/bootstrap.php | |
Plugin::load('Incentives', ['bootstrap' => false, 'routes' => true]); | |
//From /cam-website/config/routes.php | |
<?php | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Cake\Routing\Router; | |
Router::scope('/', function($routes) { | |
$routes->connect('/PrestigeLogs', ['controller' => 'PrestigeLogs', 'plugin'=>'Incentives']); | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MembershipClassesTable.php | |
namespace App\Model\Table; | |
use Cake\ORM\Table; | |
use Cake\Validation\Validator; | |
use Cake\Model\Behavior\TreeBehavior; | |
class MembershipClassesTable extends AppTable { | |
public function initialize(array $config){ |
OlderNewer