Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
<?
namespace App\Controller;
use App\Controller\AppController;
use Cake\Error\NotFoundException;
use Cake\Event\Event;
use Cake\Utility\Debugger;
use Cake\Utility\Inflector;
class UsersController extends AppController {
public function messages(){
$this->loadModel('ChatMessages');
$this->loadModel('Users');
$this->layout="json";
//$this->autoRender = false;
//$this->viewClass = 'Tools.Ajax';
//$this->RequestHandler->renderAs($this, 'json');
$users = $this->Users->find('all');
$chatMessages = $this->ChatMessages->find('all',[
<?
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\Validation\Validator;
class ChatMessagesTable extends Table {
public function initialize(array $config) {
$this->belongsTo('Users');
}
<?php
namespace App\Controller;
use App\Controller\AppController;
class ChatController extends AppController
{
public function messages(){
$this->loadModel('ChatMessages');
<?
namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\Validation\Validator;
class ChatMessagesTable extends Table {
public function initialize(array $config) {
$this->belongsTo('Users');
}
public function edit_sheet($id){
$this->loadModel('FormSections');
$this->loadModel('FormItems');
$this->loadModel('FormElements');
$form = $this->Form->get($id);
$formsections = $this->FormSections->find('all')->where(['form_id' => $id]);
$formitems = $this->FormItems->find('all');
$formelements = $this->FormElements->find('all');
$this->set('form', $form);
$this->set('formsections', $formsections);