Skip to content

Instantly share code, notes, and snippets.

<?php
$ext = pathinfo($entity->get($field)['name'], PATHINFO_EXTENSION);
if($entity->has('company')) {
$newFileName = $entity->get($field)['name'];
}
else {
$newFileName = Inflector::slug($entity->company) . ".$ext";
}
<namespace App\Routing\Route;
use Cake\Routing\Route\Route;
use Cake\ORM\TableRegistry;
class AdRoute extends Route
{
public function parse($url)
{
$params = parent::parse($url);
<?php
$agent = $this->Agents
->find()
->where(['Agents.id' => $this->Auth->user('foreign_key')])
->first();
<?php
$agent = $this->Agents
->find()
->where(['Agents.id' => $this->Auth->user('foreign_key')])
->first();
<?php
public function validationProfile(Validator $validator)
{
$validator
>requirePresence('username')
->notEmpty('username')
->add('username', [
'uniqueEmail' => [
'rule' => ['validateUnique', [/*'scope' => 'site_id'*/]],
There were 2 errors:
1) Proffer\Tests\Lib\ProfferPathTest::testDeleteFiles
Cake\Core\Exception\MissingPluginException: Plugin Proffer could not be found.
/vagrant/app/vendor/cakephp/cakephp/src/Core/Plugin.php:263
/vagrant/app/vendor/davidyell/proffer/tests/TestCase/Lib/ProfferPathTest.php:232
2) Proffer\Tests\Model\Behavior\ProfferBehaviorTest::testAfterDelete
Cake\Core\Exception\MissingPluginException: Plugin Proffer could not be found.
<?php
public function beforeSave(Event $event, Entity $entity, ArrayObject $options, ProfferPath $path = null)
{
foreach ($this->config() as $field => $settings) {
if ($entity->has($field) && is_array($entity->get($field)) &&
$entity->get($field)['error'] === UPLOAD_ERR_OK) {
if (!$path) {
$path = new ProfferPath($this->_table, $entity, $field, $settings);
<?php
protected function moveUploadedFile($file, $destination)
{
if ($this->isUploadedFile($file)) {
return move_uploaded_file($file, $destination);
}
return rename($file, $destination);
}
<?php
public function zipcodeToRegion($zipcode, $zipcodeField = 'id', $regionField = 'id')
{
$result = $this
->find()
->select($regionField)
->join([
[
'table' => 'provinces',
<?php
public function zipcodeToRegion($zipcode, $zipcodeField = 'id', $regionField = 'id')
{
$result = $this
->find()
->select($regionField)
->join([
[
'table' => 'provinces',