Skip to content

Instantly share code, notes, and snippets.

View swthate's full-sized avatar

Steven Thate swthate

  • MN
View GitHub Profile
@swthate
swthate / AppModel.php
Last active August 29, 2015 13:59 — forked from anonymous/Client.php
<?php
// File: /app/Model/AppModel.php -->
App::uses('Model', 'Model');
/**
* Application model for Cake.
*
* Add your application-wide methods in the class below, your models
* will inherit them.
<?php
array(
'Client' => array(
'id' => '2',
'name' => 'C&B Operations',
'contactname' => ''
),
'Job' => array(
(int) 0 => array(
'client_id' => '2',
@swthate
swthate / User.php
Last active August 29, 2015 14:00
User auth.
<?php
// app/Model/User.php
App::uses('AppModel', 'Model');
App::uses('SimplePasswordHasher', 'Controller/Component/Auth');
class User extends AppModel
{
public $validate = array(
'username' => array(
<?php
// app/Controller/DashboardsController.php
App::uses('AppController', 'Controller');
class DashboardsController extends AppController
{
public function index()
{
@swthate
swthate / ClientsController.php
Last active August 29, 2015 14:00
Saving Related Model Data
<?php
// File: /app/Controller/ClientsController.php
App::uses('AppController','Controller');
class ClientsController extends AppController
{
// Load the Html and Form Helper:
public $helpers = array('Html', 'Form');
@swthate
swthate / index.ctp
Last active August 29, 2015 14:00
Add CSS class to link
<?php
echo $this->Html->link(
'Add New Job',
'/jobs/add',
array(
'class' => 'button')
);
?>
@swthate
swthate / Client.php
Last active August 29, 2015 14:00
Add Client (and job)
<?php
// File: app/Model/Client.php
App::uses('AppModel','Model'); // Let cake know you need the AppModel file
class Client extends AppModel
{
// Relation with Job Model -------------
public $hasMany = array('Job');
@swthate
swthate / Client.php
Created April 29, 2014 20:00
Contain Contact
<?php
// app/Model/Client.php
App::uses('AppModel', 'Model');
/**
* Client Model
*
* @property Contact $Contact
* @property Job $Job
*/
@swthate
swthate / JobsController.php
Created May 2, 2014 18:53
Display Comment Username
<?php
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->Job->exists($id)) {
@swthate
swthate / JobsController.php
Last active August 29, 2015 14:01
Baked JobsController
<?php
/**
* Components
*
* @var array
*/
public $components = array('Paginator', 'Session');
public $pagiante = array(
'order' => array(
'Job.id' => 'desc'