This file contains hidden or 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
#!/bin/sh | |
cd /home/aavrug/public_html/repos/project/app/Console | |
php ./cake Test |
This file contains hidden or 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
$validator | |
->requirePresence('confirm_password', 'create') | |
->notEmpty('confirm_password') | |
->add('confirm_password', ['compare' => ['rule' => ['compareWith', 'password']]]); |
This file contains hidden or 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
$currentTime = Time::now(); | |
$previousDay = new Time('24 hours ago'); | |
$this->paginate = [ | |
'conditions' => [ | |
'Devices.created between ? and ?' => [ | |
$currentTime, | |
$previousDay | |
] |
This file contains hidden or 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
$previousDay = new Time('24 hours ago'); | |
$this->paginate = [ | |
'conditions' => [ | |
'Devices.created >' => $previousDay | |
], | |
]; |
This file contains hidden or 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
//$userIds is an array with key and value. the value is the user id | |
$this->paginate = [ | |
'conditions' => ['Users.id' => $userIds->toArray()] | |
]; | |
$this->paginate($this->Users); |
This file contains hidden or 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 findGrouped(Query $query, array $options) | |
{ | |
$PostsTags = TableRegistry::get('PostsTags'); | |
$Tags = TableRegistry::get('Tags'); | |
$tagIds = $PostsTags->find('list', [ | |
'conditions' => [ | |
'PostsTags.tag_id' => $options['tags'] | |
], | |
'fields' => [ |
This file contains hidden or 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 add() | |
{ | |
$this->set('con',$this->Ctrl->get()); | |
$permission = $this->Permissions->newEntity(); | |
if ($this->request->is('post')) { | |
foreach ($this->request->data as $data) { | |
$permission = $this->Permissions->patchEntity($permission, $data); | |
$this->Permissions->save($permission); | |
} | |
} |
This file contains hidden or 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
view | |
<?= $this->Form->create($permission,['class' => 'form-horizontal form-horizontal form-bordered','data-parsley-validate' => "true", 'name' => "demo-form"]) ?> | |
<?php for ($i=0; $i < 5; $i++) { ?> | |
<div class="form-group"> | |
<label class="col-md-3 control-label">Name</label> | |
<div class="col-md-9"> | |
<?php echo $this->Form->input("$i.name", ['class' => 'form-control' ,'label' => false, 'placeholder' => 'Enter Name']); ?> | |
</div> | |
</div> |
This file contains hidden or 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
if (empty($status->toArray())) { | |
$singlePost = $this->Posts->find('all', ['conditions' => ['type' => 'published', 'id' => 21]]); | |
} | |
$allPosts = $this->Posts->find('all', ['conditions' => ['type' => 'published', 'id NOT IN' => [0, 21]]]); | |
$posts = $singlePost->append($allPosts); | |
debug($posts->toArray());exit; |
This file contains hidden or 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 order_by_comments() | |
{ | |
$posts = $this->paginate($this->Posts, [ | |
'sortWhitelist' => [ | |
'id', | |
'title', | |
'total', | |
], | |
'fields' => [ | |
'id', |