Skip to content

Instantly share code, notes, and snippets.

View dakota's full-sized avatar

Walther Lalk dakota

View GitHub Profile
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName localhost
vagrant@VAGRANT-BOX ~
$ cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\vagrant>echo %cd%
Router::scope('/users', ['controller' => 'Creators'], function (RouteBuilder $routes) {
$routes->connect('/add', ['action' => 'add']);
});
<?php
$validator
->allowEmpty('number')
->add('number', 'valid', [
'rule' => function ($value) {
return preg_match('/^(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}$/', $value) === 1;
}
]);
<?php
public function add() {
$applicant = $this->Applicants->newEntity($this->request->data);
debug($applicant);
$subjects = $this->Applicants->ApplicantSubjects->Subjects->find('list');
$this->set('subjects', $subjects);
$this->set('applicant', $applicant);
}
<?php
$assets = array(
'0' => array(
'Asset' => array(
'id' => '542273cb-2490-490d-b771-4ec767094594',
'name' => 'Congregations (Dashboard)',
'alias' => 'Congregations/dashboard',
'modified' => ''
),
<?php
//Add method
public function add() {
if ($this->request->is('post')) {
$this->Truck->create();
if ($this->Truck->saveAssociated($this->request->data)) {
$this->Session->setFlash(__('The truck has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The truck could not be saved. Please, try again.'));
<?php
namespace App\View;
use Cake\View\View;
/**
* Class HintView
*
* @property \Cake\View\Helper\FormHelper $Form
* @property \Cake\View\Helper\HtmlHelper $Html
<div class="users index">
<h2><?php echo __('Users'); ?></h2>
<?php
echo "<table cellpadding='0' cellspacing='0'>
<tr>
<th>No</th>
<th>ID</th>
<th>Username</th>
<th>Role</th>
<th>Status</th>
@dakota
dakota / app_model.php
Created December 15, 2011 10:37
DB agnostic virtual fields
<?php
class AppModel extends Model {
private $sqlMap = array(
'mysql' => array(
'now' => 'NOW()',
'if' => 'IF(%1$s,%2$s,%3$s)',
'concat' => array('CONCAT(%s)', 'implode', ','),
'hour' => 'HOUR',
'year' => 'YEAR',
'date_sub' => 'DATE_SUB(%1$s, INTERVAL %2$s %3$s)',