Commit 3c795628 by Prasong Putichanchai

no message

parents
www/vendor/
www/logs/
www/tmp/
www/webroot/img/img/demos/shop/products/shop8/product2.jpg
www/webroot/img/img/demos/
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.bat]
end_of_line = crlf
[*.yml]
indent_style = space
indent_size = 2
# Uncomment the following to prevent the httpoxy vulnerability
# See: https://httpoxy.org/
#<IfModule mod_headers.c>
# RequestHeader unset Proxy
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
language: php
dist: trusty
sudo: false
php:
- 5.6
- 7.0
- 7.1
matrix:
fast_finish: true
include:
- php: 7.0
env: PHPCS=1
before_script:
- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:~2.1; fi
- if [[ $PHPCS != 1 ]]; then composer install; fi
- if [[ $PHPCS != 1 ]]; then composer require phpunit/phpunit:"^5.7|^6.0"; fi
- if [[ $PHPCS != 1 ]]; then composer run-script post-install-cmd --no-interaction; fi
script:
- if [[ $PHPCS != 1 ]]; then vendor/bin/phpunit; fi
- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests ./config ./webroot; fi
notifications:
email: false
# CakePHP Application Skeleton
[![Build Status](https://img.shields.io/travis/cakephp/app/master.svg?style=flat-square)](https://travis-ci.org/cakephp/app)
[![License](https://img.shields.io/packagist/l/cakephp/app.svg?style=flat-square)](https://packagist.org/packages/cakephp/app)
A skeleton for creating applications with [CakePHP](https://cakephp.org) 3.x.
The framework source code can be found here: [cakephp/cakephp](https://github.com/cakephp/cakephp).
## Installation
1. Download [Composer](https://getcomposer.org/doc/00-intro.md) or update `composer self-update`.
2. Run `php composer.phar create-project --prefer-dist cakephp/app [app_name]`.
If Composer is installed globally, run
```bash
composer create-project --prefer-dist cakephp/app
```
In case you want to use a custom app dir name (e.g. `/myapp/`):
```bash
composer create-project --prefer-dist cakephp/app myapp
```
You can now either use your machine's webserver to view the default home page, or start
up the built-in webserver with:
```bash
bin/cake server -p 8765
```
Then visit `http://localhost:8765` to see the welcome page.
## Update
Since this skeleton is a starting point for your application and various files
would have been modified as per your needs, there isn't a way to provide
automated upgrades, so you have to do any updates manually.
## Configuration
Read and edit `config/app.php` and setup the `'Datasources'` and any other
configuration relevant for your application.
## Layout
The app skeleton uses a subset of [Foundation](http://foundation.zurb.com/) (v5) CSS
framework by default. You can, however, replace it with any other library or
custom styles.
#!/usr/bin/env sh
################################################################################
#
# Cake is a shell script for invoking CakePHP shell commands
#
# CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
# Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
# @link https://cakephp.org CakePHP(tm) Project
# @since 1.2.0
# @license https://opensource.org/licenses/mit-license.php MIT License
#
################################################################################
# Canonicalize by following every symlink of the given name recursively
canonicalize() {
NAME="$1"
if [ -f "$NAME" ]
then
DIR=$(dirname -- "$NAME")
NAME=$(cd -P "$DIR" > /dev/null && pwd -P)/$(basename -- "$NAME")
fi
while [ -h "$NAME" ]; do
DIR=$(dirname -- "$NAME")
SYM=$(readlink "$NAME")
NAME=$(cd "$DIR" > /dev/null && cd $(dirname -- "$SYM") > /dev/null && pwd)/$(basename -- "$SYM")
done
echo "$NAME"
}
CONSOLE=$(dirname -- "$(canonicalize "$0")")
APP=$(dirname "$CONSOLE")
if [ $(basename $0) != 'cake' ]
then
exec php "$CONSOLE"/cake.php $(basename $0) "$@"
else
exec php "$CONSOLE"/cake.php "$@"
fi
exit
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Cake is a Windows batch script for invoking CakePHP shell commands
::
:: CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
:: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
::
:: Licensed under The MIT License
:: Redistributions of files must retain the above copyright notice.
::
:: @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
:: @link https://cakephp.org CakePHP(tm) Project
:: @since 2.0.0
:: @license https://opensource.org/licenses/mit-license.php MIT License
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
SET app=%0
SET lib=%~dp0
php "%lib%cake.php" %*
echo.
exit /B %ERRORLEVEL%
#!/usr/bin/php -q
<?php
// Check platform requirements
require dirname(__DIR__) . '/config/requirements.php';
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Application;
use Cake\Console\CommandRunner;
// Build the runner with an application and root executable name.
$runner = new CommandRunner(new Application(dirname(__DIR__) . '/config'), 'cake');
exit($runner->run($argv));
{
"name": "cakephp/app",
"description": "CakePHP skeleton app",
"homepage": "https://cakephp.org",
"type": "project",
"license": "MIT",
"require": {
"php": ">=5.6",
"backstageel/cakephp-gentelella-theme": "^1.2",
"cakephp/cakephp": "3.5.*",
"cakephp/migrations": "^1.0",
"cakephp/plugin-installer": "^1.0",
"josegonzalez/dotenv": "2.*",
"maiconpinto/cakephp-adminlte-theme": "^1.0",
"mobiledetect/mobiledetectlib": "2.*"
},
"require-dev": {
"cakephp/bake": "^1.1",
"cakephp/cakephp-codesniffer": "^3.0",
"cakephp/debug_kit": "^3.2",
"psy/psysh": "@stable"
},
"suggest": {
"markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
"dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.",
"phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
"cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
},
"autoload": {
"psr-4": {
"App\\": "src",
"AdminLTE\\": "src",
"Gentelella\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests",
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
}
},
"scripts": {
"post-install-cmd": "App\\Console\\Installer::postInstall",
"post-create-project-cmd": "App\\Console\\Installer::postInstall",
"post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
"check": [
"@test",
"@cs-check"
],
"cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"test": "phpunit --colors=always"
},
"prefer-stable": true,
"config": {
"sort-packages": true
}
}
#!/usr/bin/env bash
# Used as a default to seed config/.env which
# enables you to use environment variables to configure
# the aspects of your application that vary by
# environment.
#
# To use this file, first copy it into `config/.env`. Also ensure the related
# code block for loading this file is uncommented in `config/boostrap.php`
#
# In development .env files are parsed by PHP
# and set into the environment. This provides a simpler
# development workflow over standard environment variables.
export APP_NAME="__APP_NAME__"
export DEBUG="true"
export APP_ENCODING="UTF-8"
export APP_DEFAULT_LOCALE="en_US"
export SECURITY_SALT="__SALT__"
# Uncomment these to define cache configuration via environment variables.
#export CACHE_DURATION="+2 minutes"
#export CACHE_DEFAULT_URL="file://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
#export CACHE_CAKECORE_URL="file://tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
#export CACHE_CAKEMODEL_URL="file://tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
# Uncomment these to define email transport configuration via environment variables.
#export EMAIL_TRANSPORT_DEFAULT_URL=""
# Uncomment these to define database configuration via environment variables.
#export DATABASE_URL="mysql://my_app:secret@localhost/${APP_NAME}?encoding=utf8&timezone=UTC&cacheMetadata=true&quoteIdentifiers=false&persistent=false"
#export DATABASE_TEST_URL="mysql://my_app:secret@localhost/test_${APP_NAME}?encoding=utf8&timezone=UTC&cacheMetadata=true&quoteIdentifiers=false&persistent=false"
# Uncomment these to define logging configuration via environment variables.
#export LOG_DEBUG_URL="file://logs?levels[]=notice&levels[]=info&levels[]=debug&file=debug"
#export LOG_ERROR_URL="file://logs?levels[]=warning&levels[]=error&levels[]=critical&levels[]=alert&levels[]=emergency&file=error"
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.10.8
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
/*
* Configure paths required to find CakePHP + general filepath constants
*/
require __DIR__ . '/paths.php';
/*
* Bootstrap CakePHP.
*
* Does the various bits of setup that CakePHP needs to do.
* This includes:
*
* - Registering the CakePHP autoloader.
* - Setting the default application paths.
*/
require CORE_PATH . 'config' . DS . 'bootstrap.php';
use Cake\Cache\Cache;
use Cake\Console\ConsoleErrorHandler;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
use Cake\Core\Plugin;
use Cake\Database\Type;
use Cake\Datasource\ConnectionManager;
use Cake\Error\ErrorHandler;
use Cake\Http\ServerRequest;
use Cake\Log\Log;
use Cake\Mailer\Email;
use Cake\Utility\Inflector;
use Cake\Utility\Security;
/**
* Uncomment block of code below if you want to use `.env` file during development.
* You should copy `config/.env.default to `config/.env` and set/modify the
* variables as required.
*/
// if (!env('APP_NAME') && file_exists(CONFIG . '.env')) {
// $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
// $dotenv->parse()
// ->putenv()
// ->toEnv()
// ->toServer();
// }
/*
* Read configuration file and inject configuration into various
* CakePHP classes.
*
* By default there is only one configuration file. It is often a good
* idea to create multiple configuration files, and separate the configuration
* that changes from configuration that does not. This makes deployment simpler.
*/
try {
Configure::config('default', new PhpConfig());
Configure::load('app', 'default', false);
} catch (\Exception $e) {
exit($e->getMessage() . "\n");
}
/*
* Load an environment local configuration file.
* You can use a file like app_local.php to provide local overrides to your
* shared configuration.
*/
//Configure::load('app_local', 'default');
/*
* When debug = true the metadata cache should only last
* for a short time.
*/
if (Configure::read('debug')) {
Configure::write('Cache._cake_model_.duration', '+2 minutes');
Configure::write('Cache._cake_core_.duration', '+2 minutes');
}
/*
* Set server timezone to UTC. You can change it to another timezone of your
* choice but using UTC makes time calculations / conversions easier.
* Check http://php.net/manual/en/timezones.php for list of valid timezone strings.
*/
date_default_timezone_set('UTC');
/*
* Configure the mbstring extension to use the correct encoding.
*/
mb_internal_encoding(Configure::read('App.encoding'));
/*
* Set the default locale. This controls how dates, number and currency is
* formatted and sets the default language to use for translations.
*/
ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
/*
* Register application error and exception handlers.
*/
$isCli = PHP_SAPI === 'cli';
if ($isCli) {
(new ConsoleErrorHandler(Configure::read('Error')))->register();
} else {
(new ErrorHandler(Configure::read('Error')))->register();
}
/*
* Include the CLI bootstrap overrides.
*/
if ($isCli) {
require __DIR__ . '/bootstrap_cli.php';
}
/*
* Set the full base URL.
* This URL is used as the base of all absolute links.
*
* If you define fullBaseUrl in your config file you can remove this.
*/
if (!Configure::read('App.fullBaseUrl')) {
$s = null;
if (env('HTTPS')) {
$s = 's';
}
$httpHost = env('HTTP_HOST');
if (isset($httpHost)) {
Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost);
}
unset($httpHost, $s);
}
Cache::setConfig(Configure::consume('Cache'));
ConnectionManager::setConfig(Configure::consume('Datasources'));
Email::setConfigTransport(Configure::consume('EmailTransport'));
Email::setConfig(Configure::consume('Email'));
Log::setConfig(Configure::consume('Log'));
Security::setSalt(Configure::consume('Security.salt'));
/*
* The default crypto extension in 3.0 is OpenSSL.
* If you are migrating from 2.x uncomment this code to
* use a more compatible Mcrypt based implementation
*/
//Security::engine(new \Cake\Utility\Crypto\Mcrypt());
/*
* Setup detectors for mobile and tablet.
*/
ServerRequest::addDetector('mobile', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isMobile();
});
ServerRequest::addDetector('tablet', function ($request) {
$detector = new \Detection\MobileDetect();
return $detector->isTablet();
});
/*
* Enable immutable time objects in the ORM.
*
* You can enable default locale format parsing by adding calls
* to `useLocaleParser()`. This enables the automatic conversion of
* locale specific date formats. For details see
* @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
*/
Type::build('time')
->useImmutable();
Type::build('date')
->useImmutable();
Type::build('datetime')
->useImmutable();
Type::build('timestamp')
->useImmutable();
/*
* Custom Inflector rules, can be set to correctly pluralize or singularize
* table, model, controller names or whatever other string is passed to the
* inflection functions.
*/
//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
//Inflector::rules('irregular', ['red' => 'redlings']);
//Inflector::rules('uninflected', ['dontinflectme']);
//Inflector::rules('transliteration', ['/å/' => 'aa']);
/*
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on Plugin to use more
* advanced ways of loading plugins
*
* Plugin::loadAll(); // Loads all plugins at once
* Plugin::load('Migrations'); //Loads a single plugin named Migrations
*
*/
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
//Plugin::load('Gentelella',['bootstrap' => true,'routes' => true ]);
//Plugin::load('AdminLTE', ['bootstrap' => true, 'routes' => true]);
//Plugin::load('Porto',['bootstrap' => true,'routes' => true ]);
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\Core\Plugin;
/**
* Additional bootstrapping and configuration for CLI environments should
* be put here.
*/
// Set the fullBaseUrl to allow URLs to be generated in shell tasks.
// This is useful when sending email from shells.
//Configure::write('App.fullBaseUrl', php_uname('n'));
// Set logs to different files so they don't have permission conflicts.
Configure::write('Log.debug.file', 'cli-debug');
Configure::write('Log.error.file', 'cli-error');
try {
Plugin::load('Bake');
} catch (MissingPluginException $e) {
// Do not halt if the plugin is missing
}
Plugin::load('Migrations');
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license MIT License (https://opensource.org/licenses/mit-license.php)
*/
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* When using custom settings be sure to use the DS and do not add a trailing DS.
*/
/**
* The full path to the directory which holds "src", WITHOUT a trailing DS.
*/
define('ROOT', dirname(__DIR__));
/**
* The actual directory name for the application directory. Normally
* named 'src'.
*/
define('APP_DIR', 'src');
/**
* Path to the application's directory.
*/
define('APP', ROOT . DS . APP_DIR . DS);
/**
* Path to the config directory.
*/
define('CONFIG', ROOT . DS . 'config' . DS);
/**
* File path to the webroot directory.
*/
define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
/**
* Path to the tests directory.
*/
define('TESTS', ROOT . DS . 'tests' . DS);
/**
* Path to the temporary files directory.
*/
define('TMP', ROOT . DS . 'tmp' . DS);
/**
* Path to the logs directory.
*/
define('LOGS', ROOT . DS . 'logs' . DS);
/**
* Path to the cache files directory. It can be shared between hosts in a multi-server setup.
*/
define('CACHE', TMP . 'cache' . DS);
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
* CakePHP should always be installed with composer, so look there.
*/
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
/**
* Path to the cake directory.
*/
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
define('CAKE', CORE_PATH . 'src' . DS);
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.5.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
/*
* You can empty out this file, if you are certain that you match all requirements.
*/
/*
* You can remove this if you are confident that your PHP version is sufficient.
*/
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have intl installed.
*/
if (!extension_loaded('intl')) {
trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
/*
* You can remove this if you are confident you have mbstring installed.
*/
if (!extension_loaded('mbstring')) {
trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR);
}
<?php
/**
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect
* different URLs to chosen controllers and their actions (functions).
*
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
use Cake\Core\Plugin;
use Cake\Routing\RouteBuilder;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;
/**
* The default class to use for all routes
*
* The following route classes are supplied with CakePHP and are appropriate
* to set as the default:
*
* - Route
* - InflectedRoute
* - DashedRoute
*
* If no call is made to `Router::defaultRouteClass()`, the class used is
* `Route` (`Cake\Routing\Route\Route`)
*
* Note that `Route` does not do any inflections on URLs which will result in
* inconsistently cased URLs when used with `:plugin`, `:controller` and
* `:action` markers.
*
*/
Router::defaultRouteClass(DashedRoute::class);
Router::scope('/', function (RouteBuilder $routes) {
/**
* Here, we are connecting '/' (base path) to a controller called 'Pages',
* its action called 'display', and we pass a param to select the view file
* to use (in this case, src/Template/Pages/home.ctp)...
*/
$routes->connect('/', ['controller' => 'Users', 'action' => 'signin']);
/**
* ...and connect the rest of 'Pages' controller's URLs.
*/
////$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
/**
* Connect catchall routes for all controllers.
*
* Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
* `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);`
* `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);`
*
* Any route class can be used with this method, such as:
* - DashedRoute
* - InflectedRoute
* - Route
* - Or your own route class
*
* You can remove these routes once you've connected the
* routes you want in your application.
*/
$routes->fallbacks(DashedRoute::class);
});
/**
* Load all plugin routes. See the Plugin documentation on
* how to customize the loading of plugin routes.
*/
Plugin::routes();
# Copyright (c) Cake Software Foundation, Inc. (https://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.
# MIT License (https://opensource.org/licenses/mit-license.php)
CREATE TABLE i18n (
id int NOT NULL auto_increment,
locale varchar(6) NOT NULL,
model varchar(255) NOT NULL,
foreign_key int(10) NOT NULL,
field varchar(255) NOT NULL,
content text,
PRIMARY KEY (id),
UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
INDEX I18N_FIELD(model, foreign_key, field)
);
# Copyright (c) Cake Software Foundation, Inc. (https://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.
# MIT License (https://opensource.org/licenses/mit-license.php)
CREATE TABLE `sessions` (
`id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
`created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
`modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
`data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob
`expires` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.10.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
</php>
<!-- Add any additional test suites you want to run here -->
<testsuites>
<testsuite name="App Test Suite">
<directory>./tests/TestCase</directory>
</testsuite>
<!-- Add plugin test suites here. -->
</testsuites>
<!-- Setup a listener for fixtures -->
<listeners>
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector"
file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<!-- Ignore vendor tests in code coverage reports -->
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
<directory suffix=".php">./plugins/*/src/</directory>
</whitelist>
</filter>
</phpunit>
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.3.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App;
use Cake\Core\Configure;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\BaseApplication;
use Cake\Routing\Middleware\AssetMiddleware;
use Cake\Routing\Middleware\RoutingMiddleware;
/**
* Application setup class.
*
* This defines the bootstrapping logic and middleware layers you
* want to use in your application.
*/
class Application extends BaseApplication
{
/**
* Setup the middleware queue your application will use.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
* @return \Cake\Http\MiddlewareQueue The updated middleware queue.
*/
public function middleware($middlewareQueue)
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(ErrorHandlerMiddleware::class)
// Handle plugin/theme assets like CakePHP normally does.
->add(AssetMiddleware::class)
// Add routing middleware.
->add(new RoutingMiddleware($this));
return $middlewareQueue;
}
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Console;
use Cake\Utility\Security;
use Composer\Script\Event;
use Exception;
/**
* Provides installation hooks for when this application is installed via
* composer. Customize this class to suit your needs.
*/
class Installer
{
/**
* An array of directories to be made writable
*/
const WRITABLE_DIRS = [
'logs',
'tmp',
'tmp/cache',
'tmp/cache/models',
'tmp/cache/persistent',
'tmp/cache/views',
'tmp/sessions',
'tmp/tests'
];
/**
* Does some routine installation tasks so people don't have to.
*
* @param \Composer\Script\Event $event The composer event object.
* @throws \Exception Exception raised by validator.
* @return void
*/
public static function postInstall(Event $event)
{
$io = $event->getIO();
$rootDir = dirname(dirname(__DIR__));
static::createAppConfig($rootDir, $io);
static::createWritableDirectories($rootDir, $io);
// ask if the permissions should be changed
if ($io->isInteractive()) {
$validator = function ($arg) {
if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
return $arg;
}
throw new Exception('This is not a valid answer. Please choose Y or n.');
};
$setFolderPermissions = $io->askAndValidate(
'<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
$validator,
10,
'Y'
);
if (in_array($setFolderPermissions, ['Y', 'y'])) {
static::setFolderPermissions($rootDir, $io);
}
} else {
static::setFolderPermissions($rootDir, $io);
}
static::setSecuritySalt($rootDir, $io);
if (class_exists('\Cake\Codeception\Console\Installer')) {
\Cake\Codeception\Console\Installer::customizeCodeceptionBinary($event);
}
}
/**
* Create the config/app.php file if it does not exist.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function createAppConfig($dir, $io)
{
$appConfig = $dir . '/config/app.php';
$defaultConfig = $dir . '/config/app.default.php';
if (!file_exists($appConfig)) {
copy($defaultConfig, $appConfig);
$io->write('Created `config/app.php` file');
}
}
/**
* Create the `logs` and `tmp` directories.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function createWritableDirectories($dir, $io)
{
foreach (static::WRITABLE_DIRS as $path) {
$path = $dir . '/' . $path;
if (!file_exists($path)) {
mkdir($path);
$io->write('Created `' . $path . '` directory');
}
}
}
/**
* Set globally writable permissions on the "tmp" and "logs" directory.
*
* This is not the most secure default, but it gets people up and running quickly.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function setFolderPermissions($dir, $io)
{
// Change the permissions on a path and output the results.
$changePerms = function ($path, $perms, $io) {
// Get permission bits from stat(2) result.
$currentPerms = fileperms($path) & 0777;
if (($currentPerms & $perms) == $perms) {
return;
}
$res = chmod($path, $currentPerms | $perms);
if ($res) {
$io->write('Permissions set on ' . $path);
} else {
$io->write('Failed to set permissions on ' . $path);
}
};
$walker = function ($dir, $perms, $io) use (&$walker, $changePerms) {
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . '/' . $file;
if (!is_dir($path)) {
continue;
}
$changePerms($path, $perms, $io);
$walker($path, $perms, $io);
}
};
$worldWritable = bindec('0000000111');
$walker($dir . '/tmp', $worldWritable, $io);
$changePerms($dir . '/tmp', $worldWritable, $io);
$changePerms($dir . '/logs', $worldWritable, $io);
}
/**
* Set the security.salt value in the application's config file.
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @return void
*/
public static function setSecuritySalt($dir, $io)
{
$newKey = hash('sha256', Security::randomBytes(64));
static::setSecuritySaltInFile($dir, $io, $newKey, 'app.php');
}
/**
* Set the security.salt value in a given file
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @param string $newKey key to set in the file
* @param string $file A path to a file relative to the application's root
* @return void
*/
public static function setSecuritySaltInFile($dir, $io, $newKey, $file)
{
$config = $dir . '/config/' . $file;
$content = file_get_contents($config);
$content = str_replace('__SALT__', $newKey, $content, $count);
if ($count == 0) {
$io->write('No Security.salt placeholder to replace.');
return;
}
$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated Security.salt value in config/' . $file);
return;
}
$io->write('Unable to update Security.salt value.');
}
/**
* Set the APP_NAME value in a given file
*
* @param string $dir The application's root directory.
* @param \Composer\IO\IOInterface $io IO interface to write to console.
* @param string $appName app name to set in the file
* @param string $file A path to a file relative to the application's root
* @return void
*/
public static function setAppNameInFile($dir, $io, $appName, $file)
{
$config = $dir . '/config/' . $file;
$content = file_get_contents($config);
$content = str_replace('__APP_NAME__', $appName, $content, $count);
if ($count == 0) {
$io->write('No __APP_NAME__ placeholder to replace.');
return;
}
$result = file_put_contents($config, $content);
if ($result) {
$io->write('Updated __APP_NAME__ value in config/' . $file);
return;
}
$io->write('Unable to update __APP_NAME__ value.');
}
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Controller;
use Cake\Controller\Controller;
use Cake\Event\Event;
/**
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @link https://book.cakephp.org/3.0/en/controllers.html#the-app-controller
*/
class AppController extends Controller
{
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
//$this->viewBuilder()->theme('Porto');
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
/*
* Enable the following components for recommended CakePHP security settings.
* see https://book.cakephp.org/3.0/en/controllers/components/security.html
*/
//$this->loadComponent('Security');
//$this->loadComponent('Csrf');
}
/**
* Before render callback.
*
* @param \Cake\Event\Event $event The beforeRender event.
* @return \Cake\Http\Response|null|void
*/
public function beforeRender(Event $event)
{
//$this->viewBuilder()->theme('Gentelella');
//$this->viewBuilder()->theme('AdminLTE');
//$this->viewBuilder()->theme('Porto');
//$this->viewBuilder()->className('AdminLTE.AdminLTE');
//$this->viewBuilder()->theme('Porto');
//$this->viewBuilder()->className('Porto.Porto');
// Note: These defaults are just to get started quickly with development
// and should not be used in production. You should instead set "_serialize"
// in each action as required.
if (!array_key_exists('_serialize', $this->viewVars) &&
in_array($this->response->type(), ['application/json', 'application/xml'])
) {
$this->set('_serialize', true);
//$this->set('theme', Configure::read('Theme'));
}
//$this->set('theme', Configure::read('Theme'));
}
function checkToken(){
if(empty($this->request->getHeaderLine('Authorization'))){
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.3.4
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Controller;
use Cake\Event\Event;
/**
* Error Handling Controller
*
* Controller used by ExceptionRenderer to render error responses.
*/
class ErrorController extends AppController
{
/**
* Initialization hook method.
*
* @return void
*/
public function initialize()
{
$this->loadComponent('RequestHandler');
}
/**
* beforeFilter callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function beforeFilter(Event $event)
{
}
/**
* beforeRender callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->viewBuilder()->setTemplatePath('Error');
}
/**
* afterFilter callback.
*
* @param \Cake\Event\Event $event Event.
* @return \Cake\Http\Response|null|void
*/
public function afterFilter(Event $event)
{
}
}
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://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. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.2.9
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Controller;
use Cake\Core\Configure;
use Cake\Network\Exception\ForbiddenException;
use Cake\Network\Exception\NotFoundException;
use Cake\View\Exception\MissingTemplateException;
/**
* Static content controller
*
* This controller will render views from Template/Pages/
*
* @link https://book.cakephp.org/3.0/en/controllers/pages-controller.html
*/
class PagesController extends AppController
{
/**
* Displays a view
*
* @param array ...$path Path segments.
* @return \Cake\Http\Response|null
* @throws \Cake\Network\Exception\ForbiddenException When a directory traversal attempt.
* @throws \Cake\Network\Exception\NotFoundException When the view file could not
* be found or \Cake\View\Exception\MissingTemplateException in debug mode.
*/
public function index(){
}
public function display(...$path)
{
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
if (in_array('..', $path, true) || in_array('.', $path, true)) {
throw new ForbiddenException();
}
$page = $subpage = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
$this->set(compact('page', 'subpage'));
try {
$this->render(implode('/', $path));
} catch (MissingTemplateException $exception) {
if (Configure::read('debug')) {
throw $exception;
}
throw new NotFoundException();
}
}
}
<?php
namespace App\Controller;
use App\Controller\AppController;
/**
* UserPersonals Controller
*
*
* @method \App\Model\Entity\UserPersonal[] paginate($object = null, array $settings = [])
*/
class UserPersonalsController extends AppController
{
/**
* Index method
*
* @return \Cake\Http\Response|void
*/
public function index()
{
$userPersonals = $this->paginate($this->UserPersonals);
$this->set(compact('userPersonals'));
$this->set('_serialize', ['userPersonals']);
}
/**
* View method
*
* @param string|null $id User Personal id.
* @return \Cake\Http\Response|void
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function view($id = null)
{
$userPersonal = $this->UserPersonals->get($id, [
'contain' => []
]);
$this->set('userPersonal', $userPersonal);
$this->set('_serialize', ['userPersonal']);
}
/**
* Add method
*
* @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
*/
public function add()
{
$userPersonal = $this->UserPersonals->newEntity();
if ($this->request->is('post')) {
$userPersonal = $this->UserPersonals->patchEntity($userPersonal, $this->request->getData());
if ($this->UserPersonals->save($userPersonal)) {
$this->Flash->success(__('The user personal has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The user personal could not be saved. Please, try again.'));
}
$this->set(compact('userPersonal'));
$this->set('_serialize', ['userPersonal']);
}
/**
* Edit method
*
* @param string|null $id User Personal id.
* @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
* @throws \Cake\Network\Exception\NotFoundException When record not found.
*/
public function edit($id = null)
{
$userPersonal = $this->UserPersonals->get($id, [
'contain' => []
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$userPersonal = $this->UserPersonals->patchEntity($userPersonal, $this->request->getData());
if ($this->UserPersonals->save($userPersonal)) {
$this->Flash->success(__('The user personal has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The user personal could not be saved. Please, try again.'));
}
$this->set(compact('userPersonal'));
$this->set('_serialize', ['userPersonal']);
}
/**
* Delete method
*
* @param string|null $id User Personal id.
* @return \Cake\Http\Response|null Redirects to index.
* @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
*/
public function delete($id = null)
{
$this->request->allowMethod(['post', 'delete']);
$userPersonal = $this->UserPersonals->get($id);
if ($this->UserPersonals->delete($userPersonal)) {
$this->Flash->success(__('The user personal has been deleted.'));
} else {
$this->Flash->error(__('The user personal could not be deleted. Please, try again.'));
}
return $this->redirect(['action' => 'index']);
}
}
<?php
namespace App\Controller;
use App\Controller\AppController;
use Cake\Core\Configure;
use Cake\Http\Client;
use Cake\Routing\Router;
class UsersController extends AppController
{
public function index()
{
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
public function signin()
{
$this->viewBuilder()->layout('blank');
}
#Signin
public function verify()
{
$this->viewBuilder()->layout('blank');
$data = $this->request->data();
#$data['data']['ip'] = $this->request->clientIp();
if(!empty($data)){
if(!empty($data['data']['username']) && !empty($data['data']['password'])){
$data['data']['ip'] = $this->request->clientIp();#prr($data);
$api_core_signin = Configure::read('Config.apiCore.signin');
$http = new Client();
$response = $http->post($api_core_signin,$data['data'])->body();
$response = json_decode($response,'_full');#prd($response);
if(!empty($response)){
if(trim($response['status']) == 'Success'){
$url = Router::url(['controller' => 'Homes', 'action' => 'index'], true);
echo "<script>setTimeout(function(){Login.onLogin('".$response['result']['token']."','".$url."','".$response['result']['topic']."')},1000);</script>";
#echo "<script>setTimeout(function(){alert('".$response['result']['token']."')},1000);</script>";
#echo "<script>Login.onLogin('".$response['result']['token']."','".$url."','".$response['result']['topic']."');</script>";
#echo "<button onclick=Login.onLogin('".$response['result']['token']."','".$url."','".$response['result']['topic']."')>CLICK</button>";
#------------------------------------------------------------------
$param = [];
$param['topic'] = '/topics/'.$response['result']['topic'];
$param['title'] = '';
$param['message'] = '';
$param['badge'] = 1;
#$api_notification = 'http://connect05.pakgon.com/api/Notifications/push';
$api_notification = Configure::read('Config.apiCommunication.getNotification');
$http = new Client();
$options = [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
]
];
$response = $http->post($api_notification, $param, $options)->body();
#prr($response);
#------------------------------------------------------------------
die;
}else{
$this->Flash->error(__('Verify Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}else{
$this->Flash->error(__('Verify Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}else{
$this->Flash->error(__('Data Empty'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}
}
public function signup()
{
$this->viewBuilder()->layout('blank');
}
#---------------------------------------------------------------------------------------------------
#Signup
public function createAccount()
{
$this->viewBuilder()->layout('blank');
$data = $this->request->data();
if(!empty($data)){
if($this->validateAccount($data)){
$data['data']['ip'] = $this->request->clientIp();#prr($data);
$api_core_create_account = Configure::read('Config.apiCore.createAccount');
$http = new Client();
$response = $http->post($api_core_create_account,$data)->body();#prd($response);
$response = json_decode($response,'_full');
//debug($response);exit();
if(!empty($response)){
if(trim($response['status']) == 'Success'){
$this->Flash->success(__('create Account completed.'));
return $this->redirect(['controller' => 'Users', 'action' => 'pinCode/'.$response['result']['data']['token']]);
} elseif ($response['result']['message'] == 'Email Duplicate'){
$this->Flash->error(__('Email Duplicate'));
return $this->redirect(['controller' => 'Users', 'action' => 'signup']);
}else{
$this->Flash->error(__('create Account Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'signup']);
}
}
}else{
$this->Flash->error(__('Data Empty'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}
die;
}
#---------------------------------------------------------------------------------------------------
function validateAccount($data = null)
{
$error = [];
if(!empty($error)){
$this->set('error',$error);
return false;
}else{
return true;
}
}
public function notification()
{
$this->viewBuilder()->layout('blank');
}
#Verify Pin Code
public function pinCode($token=null)
{
if(empty($token)) die;
$this->viewBuilder()->layout('blank');
$data = $this->request->data();
if(!empty($data)){
$api_core_verify_pin_code = Configure::read('Config.apiCore.verifyPinCode');
$http = new Client();
#$response = json_decode($http->post($api_core_verify_pin_code,$data)->body(),'_full');
$response = $http->post($api_core_verify_pin_code,$data)->body();
$response = json_decode($response,'_full');
if(!empty($response)){
if(trim($response['status']) == 'Success'){
$this->Flash->success(__('Verify Completed.'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}else{
$this->Flash->error(__('Pin Code Invalid'));
return $this->redirect(['controller' => 'Users', 'action' => 'pinCode/'.$token]);
}
}
}
$this->set(array('token' => $token, '_serialize' => array('token')));
}
#---------------------------------------------------------------------------------------------------
#Forgot Password
public function forgotPassword()
{
$this->viewBuilder()->layout('blank');
$data = $this->request->data();
#$data['data']['ip'] = $this->request->clientIp();
if(!empty($data)){
if(!empty($data['data']['username'])){
$data['data']['ip'] = $this->request->clientIp();#prr($data);
$api_core_forgotPassword = Configure::read('Config.apiCore.forgotPassword');
$http = new Client();
$response = $http->post($api_core_forgotPassword,$data['data'])->body();
$response = json_decode($response,'_full');#debug($response);
if(!empty($response)){
if(trim($response['status']) == 'Success'){
$this->Flash->success(__('Completed.'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}else{
$this->Flash->error(__('Forgot Password Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'forgotPassword']);
}
}else{
$this->Flash->error(__('Forgot Password Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'forgotPassword']);
}
}else{
$this->Flash->error(__('Data Empty'));
return $this->redirect(['controller' => 'Users', 'action' => 'forgotPassword']);
}
}
}
#---------------------------------------------------------------------------------------------------
#Change Password
public function changePassword()
{
$this->viewBuilder()->layout('blank');
$data = $this->request->data();#debug($data);exit();
if(!empty($data)){
if($this->validateAccount($data)){
$data['data']['ip'] = $this->request->clientIp();#debug($data);exit();
$api_core_change_password = Configure::read('Config.apiCore.changePassword');#debug($api_core_change_password);exit();
$http = new Client();
#$response = json_decode($http->post($api_core_change_password,$data)->body(),'_full');
$response = $http->post($api_core_change_password,$data)->body();
#debug($response);exit();
$response = json_decode($response,'_full');
#debug($response);exit();
if(!empty($response)){
#if(trim($response['status']) == 'Success' && !empty($response['result']['type'])){
if(trim($response['status']) == 'Success'){
#$this->response->withHeader('Authorization', 'Bearer '.$response['result']['token']);
#$url = $this->Url->build(['controller' => 'Homes', 'action' => 'index'], true);
$url = Router::url(['controller' => 'Users', 'action' => 'signup'], true);
#echo "<script>Login.onLogin('".$response['result']['token']."','".$url."');</script>";die;
$this->Flash->success(__('change Password completed.'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}else{
$this->Flash->error(__('change Password Fail'));
return $this->redirect(['controller' => 'Users', 'action' => 'signup']);
}
}
}else{
$this->Flash->error(__('Data Empty'));
return $this->redirect(['controller' => 'Users', 'action' => 'signin']);
}
}
}
#---------------------------------------------------------------------------------------------------
public function signout()
{
$this->checkToken();
}
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* AppAcces Entity
*
* @property int $id
* @property string $person_card_no
* @property int $master_prefix_id
* @property string $firstname_th
* @property string $lastname_th
* @property string $firstname_en
* @property string $lastname_en
* @property string $gender
* @property \Cake\I18n\FrozenDate $birthdate
* @property string $moblie_no
* @property string $phone_no
* @property string $email
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $user_id
* @property string $blood_group
* @property string $address
*
* @property \App\Model\Entity\MasterPrefix $master_prefix
* @property \App\Model\Entity\User $user
*/
class AppAcce extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'user_id' => true,
'master_app_id' => true,
'is_used' => true,
'create_uid' => true,
'created' => true,
'update_uid' => true,
'modified' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterApps Entity
*
* @property int $id
* @property string $person_card_no
* @property int $master_prefix_id
* @property string $firstname_th
* @property string $lastname_th
* @property string $firstname_en
* @property string $lastname_en
* @property string $gender
* @property \Cake\I18n\FrozenDate $birthdate
* @property string $moblie_no
* @property string $phone_no
* @property string $email
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $user_id
* @property string $blood_group
* @property string $address
*
* @property \App\Model\Entity\MasterPrefix $master_prefix
* @property \App\Model\Entity\User $user
*/
class MasterApps extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_category_id' => true,
'master_organization_id' => true,
'app_name_th' => true,
'app_name_en' => true,
'order_seq' => true,
'is_ads' => true,
'app_img_path' => true,
'app_url_path' => true,
'is_used' => true,
'create_uid' => true,
'created' => true,
'update_uid' => true,
'modified' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterBusinessType Entity
*
* @property int $id
* @property int $master_language_id
* @property string $business_type_name
* @property int $seq_no
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\MasterLanguage $master_language
*/
class MasterBusinessType extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_language_id' => true,
'business_type_name' => true,
'seq_no' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'master_language' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterCategorie Entity
*
* @property int $id
* @property string $cat_name_th
* @property string $cat_name_en
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*/
class MasterCategorie extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'cat_name_th' => true,
'cat_name_en' => true,
'cat_img_path' => true,
'start_date' => true,
'end_date' => true,
'order_seq' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterCountry Entity
*
* @property int $id
* @property string $country_code
* @property string $country_name_th
* @property string $country_name_en
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*/
class MasterCountry extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'country_code' => true,
'country_name_th' => true,
'country_name_en' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterDepartment Entity
*
* @property int $id
* @property int $master_organization_id
* @property string $dept_name_th
* @property string $dept_name_en
* @property string $dept_abbr_th
* @property string $dept_abbr_en
* @property int $order_seq
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\MasterOrganization $master_organization
* @property \App\Model\Entity\ArticleAccess[] $article_accesses
* @property \App\Model\Entity\MasterOrganizationPosition[] $master_organization_positions
* @property \App\Model\Entity\MasterSection[] $master_sections
*/
class MasterDepartment extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_organization_id' => true,
'dept_name_th' => true,
'dept_name_en' => true,
'dept_abbr_th' => true,
'dept_abbr_en' => true,
'order_seq' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'master_organization' => true,
'article_accesses' => true,
'master_organization_positions' => true,
'master_sections' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterDistrict Entity
*
* @property int $id
* @property int $master_province_id
* @property string $district_code
* @property string $district_name_th
* @property string $district_name_en
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\MasterProvince $master_province
*/
class MasterDistrict extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_province_id' => true,
'district_code' => true,
'district_name_th' => true,
'district_name_en' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'master_province' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterLanguage Entity
*
* @property int $id
* @property string $language_display
* @property string $language_th
* @property string $language_en
* @property string $language_abbr
* @property int $seq_no
* @property bool $is_used
* @property \Cake\I18n\FrozenTime $created
* @property int $created_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $modified_by
*
* @property \App\Model\Entity\UserDefaultLanguage[] $user_default_languages
*/
class MasterLanguage extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'language_display' => true,
'language_th' => true,
'language_en' => true,
'language_abbr' => true,
'seq_no' => true,
'is_used' => true,
'created' => true,
'created_by' => true,
'modified' => true,
'modified_by' => true,
'user_default_languages' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterOrganization Entity
*
* @property int $id
* @property string $org_name_th
* @property string $org_name_en
* @property string $org_abbr_th
* @property string $org_abbr_en
* @property int $order_seq
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $bussiness_type_id
*
* @property \App\Model\Entity\BussinessType $bussiness_type
* @property \App\Model\Entity\ArticleAccess[] $article_accesses
* @property \App\Model\Entity\MasterDepartment[] $master_departments
* @property \App\Model\Entity\MasterOrganizationPosition[] $master_organization_positions
*/
class MasterOrganization extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'org_name_th' => true,
'org_name_en' => true,
'org_abbr_th' => true,
'org_abbr_en' => true,
'order_seq' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'bussiness_type_id' => true,
'bussiness_type' => true,
'article_accesses' => true,
'master_departments' => true,
'master_organization_positions' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterOrganizationPosition Entity
*
* @property int $id
* @property int $master_organization_id
* @property int $master_department_id
* @property int $master_section_id
* @property int $master_language_id
* @property string $organization_position_name
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\MasterOrganization $master_organization
* @property \App\Model\Entity\MasterDepartment $master_department
* @property \App\Model\Entity\MasterSection $master_section
* @property \App\Model\Entity\MasterLanguage $master_language
*/
class MasterOrganizationPosition extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_organization_id' => true,
'master_department_id' => true,
'master_section_id' => true,
'master_language_id' => true,
'organization_position_name' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'master_organization' => true,
'master_department' => true,
'master_section' => true,
'master_language' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* MasterProvince Entity
*
* @property int $id
* @property int $master_country_id
* @property string $province_code
* @property string $province_name_th
* @property string $province_name_en
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\MasterCountry $master_country
* @property \App\Model\Entity\MasterDistrict[] $master_districts
*/
class MasterProvince extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_country_id' => true,
'province_code' => true,
'province_name_th' => true,
'province_name_en' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'master_country' => true,
'master_districts' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* SubjectEnroll Entity
*
* @property int $id
* @property int $subject_id
* @property int $user_id
* @property int $master_organization_id
* @property string $card_code
* @property bool $is_used
* @property \Cake\I18n\FrozenTime $created
* @property int $create_uid
* @property \Cake\I18n\FrozenTime $modified
* @property int $update_uid
*
* @property \App\Model\Entity\Subject $subject
* @property \App\Model\Entity\User $user
* @property \App\Model\Entity\MasterOrganization $master_organization
*/
class SubjectEnroll extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'subject_id' => true,
'user_id' => true,
'master_organization_id' => true,
'card_code' => true,
'is_used' => true,
'created' => true,
'create_uid' => true,
'modified' => true,
'update_uid' => true
/*'subject' => true,
'user' => true,
'master_organization' => true*/
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* UserName Entity
*
* @property int $id
* @property int $faculty_id
* @property int $role_id
* @property string $ref_code
* @property string $username
* @property string $password
* @property int $name_prefix_id
* @property string $first_name
* @property string $last_name
* @property string $email
* @property string $office_phone
* @property string $mobile_phone
* @property \Cake\I18n\FrozenDate $birth_date
* @property string $address
* @property string $moo
* @property string $road
* @property string $sub_district
* @property string $district
* @property string $province
* @property string $zipcode
* @property string $status
* @property string $picture_path
* @property \Cake\I18n\FrozenTime $created
* @property \Cake\I18n\FrozenTime $modified
*
* @property \App\Model\Entity\Faculty $faculty
* @property \App\Model\Entity\Role $role
* @property \App\Model\Entity\NamePrefix $name_prefix
*/
class UserName extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'faculty_id' => true,
'role_id' => true,
'ref_code' => true,
'username' => true,
'password' => true,
'name_prefix_id' => true,
'first_name' => true,
'last_name' => true,
'email' => true,
'office_phone' => true,
'mobile_phone' => true,
'birth_date' => true,
'address' => true,
'moo' => true,
'road' => true,
'sub_district' => true,
'district' => true,
'province' => true,
'zipcode' => true,
'status' => true,
'picture_path' => true,
'created' => true,
'modified' => true,
'faculty' => true,
'role' => true,
'name_prefix' => true
];
/**
* Fields that are excluded from JSON versions of the entity.
*
* @var array
*/
protected $_hidden = [
'password'
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* UserPersonList Entity
*
* @property int $id
* @property int $master_organization_id
* @property int $master_department_id
* @property int $master_section_id
* @property string $card_code
* @property string $first_name
* @property string $last_name
* @property int $master_user_type_id
* @property int $user_id
* @property bool $is_used
* @property \Cake\I18n\FrozenTime $created
* @property int $create_uid
* @property \Cake\I18n\FrozenTime $modified
* @property int $update_uid
*
* @property \App\Model\Entity\MasterOrganization $master_organization
* @property \App\Model\Entity\MasterDepartment $master_department
* @property \App\Model\Entity\MasterSection $master_section
* @property \App\Model\Entity\MasterUserType $master_user_type
* @property \App\Model\Entity\User $user
*/
class UserPersonList extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'master_organization_id' => true,
'master_department_id' => true,
'master_section_id' => true,
'card_code' => true,
'first_name' => true,
'last_name' => true,
'master_user_type_id' => true,
'user_id' => true,
'is_used' => true,
'created' => true,
'create_uid' => true,
'modified' => true,
'update_uid' => true,
'master_prefix_id' => true
/*'master_organization' => true,
'master_department' => true,
'master_section' => true,
'master_user_type' => true,
'user' => true*/
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* UserPersonal Entity
*
* @property int $id
* @property string $person_card_no
* @property int $master_prefix_id
* @property string $firstname_th
* @property string $lastname_th
* @property string $firstname_en
* @property string $lastname_en
* @property string $gender
* @property \Cake\I18n\FrozenDate $birthdate
* @property string $moblie_no
* @property string $phone_no
* @property string $email
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $user_id
* @property string $blood_group
* @property string $address
*
* @property \App\Model\Entity\MasterPrefix $master_prefix
* @property \App\Model\Entity\User $user
*/
class UserPersonal extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'person_card_no' => true,
'master_prefix_id' => true,
'firstname_th' => true,
'lastname_th' => true,
'firstname_en' => true,
'lastname_en' => true,
'gender' => true,
'birthdate' => true,
'moblie_no' => true,
'phone_no' => true,
'email' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'user_id' => true,
'blood_group' => true,
'address' => true,
'master_prefix' => true,
'user' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* UserProfile Entity
*
* @property int $id
* @property int $user_id
* @property int $organize_id
* @property int $dept_id
* @property int $section_id
* @property string $card_code
* @property int $user_type_id
* @property string $img_path
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $position_org
* @property int $position_edu
* @property \Cake\I18n\FrozenDate $enter_date
* @property string $address
* @property int $master_business_type_id
* @property string $phone_no
* @property int $master_organization_position_id
*/
class UserProfile extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'user_id' => true,
'organize_id' => true,
'dept_id' => true,
'section_id' => true,
'card_code' => true,
'user_type_id' => true,
'img_path' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'position_org' => true,
'position_edu' => true,
'enter_date' => true,
'address' => true,
'master_business_type_id' => true,
'phone_no' => true,
'master_organization_position_id' => true
];
}
<?php
namespace App\Model\Entity;
use Cake\ORM\Entity;
/**
* UserProfile Entity
*
* @property int $id
* @property int $user_id
* @property int $organize_id
* @property int $dept_id
* @property int $section_id
* @property string $card_code
* @property int $user_type_id
* @property string $img_path
* @property bool $is_used
* @property int $created_by
* @property \Cake\I18n\FrozenTime $created
* @property int $modified_by
* @property \Cake\I18n\FrozenTime $modified
* @property int $position_org
* @property int $position_edu
* @property \Cake\I18n\FrozenDate $enter_date
* @property string $address
* @property int $master_bussiness_type_id
*
* @property \App\Model\Entity\User $user
*/
class UserProfile extends Entity
{
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array
*/
protected $_accessible = [
'user_id' => true,
'organize_id' => true,
'dept_id' => true,
'section_id' => true,
'card_code' => true,
'user_type_id' => true,
'img_path' => true,
'is_used' => true,
'created_by' => true,
'created' => true,
'modified_by' => true,
'modified' => true,
'position_org' => true,
'position_edu' => true,
'enter_date' => true,
'address' => true,
'master_bussiness_type_id' => true,
'user' => true
];
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* AppAccess Model
*
* @property |\Cake\ORM\Association\HasMany $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterCategorie get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterCategorie newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterCategorie patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class AppAccessTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('core.app_access');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
// $this->belongsTo('Users', [
// 'foreignKey' => 'user_id',
// 'joinType' => 'INNER'
// ]);
// $this->belongsTo('MasterCategories', [
// 'foreignKey' => 'master_category_id'
// ]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('user_id')
->allowEmpty('user_id');
$validator
->scalar('master_app_id')
->allowEmpty('master_app_id');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
// public static function defaultConnectionName()
// {
// return 'core';
// }
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterApps Model
*
* @property |\Cake\ORM\Association\HasMany $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterCategorie get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterCategorie newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterCategorie patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterAppsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_apps');
$this->setDisplayField('id');
$this->setPrimaryKey('master_category_id');
$this->addBehavior('Timestamp');
$this->hasMany('MasterApps', [
'foreignKey' => 'master_category_id',
]);
// $this->belongsTo('MasterCategories', [
// 'foreignKey' => 'master_category_id',
// 'joinType' => 'INNER'
// ]);
// $this->belongsTo('MasterCategories', [
// 'foreignKey' => 'master_category_id'
// ]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('master_category_id')
->allowEmpty('master_category_id');
$validator
->scalar('master_organization_id')
->allowEmpty('master_organization_id');
$validator
->scalar('app_name_th')
->allowEmpty('app_name_th');
$validator
->scalar('app_name_en')
->allowEmpty('app_name_en');
$validator
->scalar('order_seq')
->allowEmpty('order_seq');
$validator
->scalar('is_ads')
->allowEmpty('is_ads');
$validator
->scalar('app_img_path')
->allowEmpty('app_img_path');
$validator
->scalar('app_url_path')
->allowEmpty('app_url_path');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterBusinessTypes Model
*
* @property \App\Model\Table\MasterLanguagesTable|\Cake\ORM\Association\BelongsTo $MasterLanguages
*
* @method \App\Model\Entity\MasterBusinessType get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterBusinessType newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterBusinessType[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterBusinessType|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterBusinessType patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterBusinessType[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterBusinessType findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterBusinessTypesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_business_types');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterLanguages', [
'foreignKey' => 'master_language_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('business_type_name')
->allowEmpty('business_type_name');
$validator
->allowEmpty('seq_no');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['master_language_id'], 'MasterLanguages'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterCategories Model
*
* @property |\Cake\ORM\Association\HasMany $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterCategorie get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterCategorie newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterCategorie patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterCategoriesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_categories');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterApps', [
'foreignKey' => 'master_category_id'
]);
// $this->hasMany('MasterApps', [
// 'foreignKey' => 'master_category_id'
// ]);
// $this->hasMany('UserHomeplaces', [
// 'foreignKey' => 'master_country_id'
// ]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('cat_name_th')
->allowEmpty('cat_name_th');
$validator
->scalar('cat_name_en')
->allowEmpty('cat_name_en');
$validator
->scalar('cat_img_path')
->allowEmpty('cat_img_path');
$validator
->scalar('start_date')
->allowEmpty('start_date');
$validator
->scalar('end_date')
->allowEmpty('end_date');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterCategoryBanners Model
*
* @property |\Cake\ORM\Association\HasMany $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterCategorie get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterCategorie newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterCategorie patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterCategorie findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterCategoryBannersTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_category_banners');
$this->setDisplayField('id');
$this->setPrimaryKey('master_category_id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterCategories', [
'foreignKey' => 'id',
'joinType' => 'INNER'
]);
// $this->hasMany('MasterApps', [
// 'foreignKey' => 'master_category_id'
// ]);
// $this->hasMany('AppAccess', [
// 'foreignKey' => 'master_app_id'
// ]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('master_category_id')
->allowEmpty('master_category_id');
$validator
->scalar('banner_path')
->allowEmpty('banner_path');
$validator
->scalar('seq_no')
->allowEmpty('seq_no');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterCountries Model
*
* @property |\Cake\ORM\Association\HasMany $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterCountry get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterCountry newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterCountry[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterCountry|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterCountry patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterCountry[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterCountry findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterCountriesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_countries');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->hasMany('MasterProvinces', [
'foreignKey' => 'master_country_id'
]);
$this->hasMany('UserHomeplaces', [
'foreignKey' => 'master_country_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('country_code')
->allowEmpty('country_code');
$validator
->scalar('country_name_th')
->allowEmpty('country_name_th');
$validator
->scalar('country_name_en')
->allowEmpty('country_name_en');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterDepartments Model
*
* @property \App\Model\Table\MasterOrganizationsTable|\Cake\ORM\Association\BelongsTo $MasterOrganizations
* @property \App\Model\Table\ArticleAccessesTable|\Cake\ORM\Association\HasMany $ArticleAccesses
* @property \App\Model\Table\MasterOrganizationPositionsTable|\Cake\ORM\Association\HasMany $MasterOrganizationPositions
* @property \App\Model\Table\MasterSectionsTable|\Cake\ORM\Association\HasMany $MasterSections
*
* @method \App\Model\Entity\MasterDepartment get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterDepartment newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterDepartment[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterDepartment|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterDepartment patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterDepartment[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterDepartment findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterDepartmentsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_departments');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterOrganizations', [
'foreignKey' => 'master_organization_id',
'joinType' => 'INNER'
]);
$this->hasMany('ArticleAccesses', [
'foreignKey' => 'master_department_id'
]);
$this->hasMany('MasterOrganizationPositions', [
'foreignKey' => 'master_department_id'
]);
$this->hasMany('MasterSections', [
'foreignKey' => 'master_department_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('dept_name_th')
->allowEmpty('dept_name_th');
$validator
->scalar('dept_name_en')
->allowEmpty('dept_name_en');
$validator
->scalar('dept_abbr_th')
->allowEmpty('dept_abbr_th');
$validator
->scalar('dept_abbr_en')
->allowEmpty('dept_abbr_en');
$validator
->integer('order_seq')
->allowEmpty('order_seq');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->integer('created_by')
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->integer('modified_by')
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['master_organization_id'], 'MasterOrganizations'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterDistricts Model
*
* @property \App\Model\Table\MasterProvincesTable|\Cake\ORM\Association\BelongsTo $MasterProvinces
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterDistrict get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterDistrict newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterDistrict[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterDistrict|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterDistrict patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterDistrict[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterDistrict findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterDistrictsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_districts');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterProvinces', [
'foreignKey' => 'master_province_id',
'joinType' => 'INNER'
]);
$this->hasMany('UserHomeplaces', [
'foreignKey' => 'master_district_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('district_code')
->allowEmpty('district_code');
$validator
->scalar('district_name_th')
->allowEmpty('district_name_th');
$validator
->scalar('district_name_en')
->allowEmpty('district_name_en');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['master_province_id'], 'MasterProvinces'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterLanguages Model
*
* @property |\Cake\ORM\Association\HasMany $ArticleQuestionChoiceTranslations
* @property |\Cake\ORM\Association\HasMany $ArticleQuestionTranslations
* @property |\Cake\ORM\Association\HasMany $ArticleTranslations
* @property |\Cake\ORM\Association\HasMany $MasterBusinessTypes
* @property |\Cake\ORM\Association\HasMany $MasterOrganizationPositions
* @property \App\Model\Table\UserDefaultLanguagesTable|\Cake\ORM\Association\HasMany $UserDefaultLanguages
*
* @method \App\Model\Entity\MasterLanguage get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterLanguage newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterLanguage[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterLanguage|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterLanguage patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterLanguage[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterLanguage findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterLanguagesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_languages');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->hasMany('ArticleQuestionChoiceTranslations', [
'foreignKey' => 'master_language_id'
]);
$this->hasMany('ArticleQuestionTranslations', [
'foreignKey' => 'master_language_id'
]);
$this->hasMany('ArticleTranslations', [
'foreignKey' => 'master_language_id'
]);
$this->hasMany('MasterBusinessTypes', [
'foreignKey' => 'master_language_id'
]);
$this->hasMany('MasterOrganizationPositions', [
'foreignKey' => 'master_language_id'
]);
$this->hasMany('UserDefaultLanguages', [
'foreignKey' => 'master_language_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('language_display')
->requirePresence('language_display', 'create')
->notEmpty('language_display');
$validator
->scalar('language_th')
->allowEmpty('language_th');
$validator
->scalar('language_en')
->allowEmpty('language_en');
$validator
->scalar('language_abbr')
->requirePresence('language_abbr', 'create')
->notEmpty('language_abbr');
$validator
->requirePresence('seq_no', 'create')
->notEmpty('seq_no');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterOrganizationPositions Model
*
* @property \App\Model\Table\MasterOrganizationsTable|\Cake\ORM\Association\BelongsTo $MasterOrganizations
* @property \App\Model\Table\MasterDepartmentsTable|\Cake\ORM\Association\BelongsTo $MasterDepartments
* @property \App\Model\Table\MasterSectionsTable|\Cake\ORM\Association\BelongsTo $MasterSections
* @property \App\Model\Table\MasterLanguagesTable|\Cake\ORM\Association\BelongsTo $MasterLanguages
*
* @method \App\Model\Entity\MasterOrganizationPosition get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganizationPosition findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterOrganizationPositionsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_organization_positions');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterOrganizations', [
'foreignKey' => 'master_organization_id'
]);
$this->belongsTo('MasterDepartments', [
'foreignKey' => 'master_department_id'
]);
$this->belongsTo('MasterSections', [
'foreignKey' => 'master_section_id'
]);
$this->belongsTo('MasterLanguages', [
'foreignKey' => 'master_language_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('organization_position_name')
->allowEmpty('organization_position_name');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['master_organization_id'], 'MasterOrganizations'));
$rules->add($rules->existsIn(['master_department_id'], 'MasterDepartments'));
$rules->add($rules->existsIn(['master_section_id'], 'MasterSections'));
$rules->add($rules->existsIn(['master_language_id'], 'MasterLanguages'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterOrganizations Model
*
* @property \App\Model\Table\BussinessTypesTable|\Cake\ORM\Association\BelongsTo $BussinessTypes
* @property \App\Model\Table\ArticleAccessesTable|\Cake\ORM\Association\HasMany $ArticleAccesses
* @property \App\Model\Table\MasterDepartmentsTable|\Cake\ORM\Association\HasMany $MasterDepartments
* @property \App\Model\Table\MasterOrganizationPositionsTable|\Cake\ORM\Association\HasMany $MasterOrganizationPositions
*
* @method \App\Model\Entity\MasterOrganization get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterOrganization newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterOrganization[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganization|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterOrganization patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganization[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterOrganization findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterOrganizationsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_organizations');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('BussinessTypes', [
'foreignKey' => 'bussiness_type_id'
]);
$this->hasMany('ArticleAccesses', [
'foreignKey' => 'master_organization_id'
]);
$this->hasMany('MasterDepartments', [
'foreignKey' => 'master_organization_id'
]);
$this->hasMany('MasterOrganizationPositions', [
'foreignKey' => 'master_organization_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('org_name_th')
->allowEmpty('org_name_th');
$validator
->scalar('org_name_en')
->allowEmpty('org_name_en');
$validator
->scalar('org_abbr_th')
->allowEmpty('org_abbr_th');
$validator
->scalar('org_abbr_en')
->allowEmpty('org_abbr_en');
$validator
->integer('order_seq')
->allowEmpty('order_seq');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->integer('created_by')
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->integer('modified_by')
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['bussiness_type_id'], 'BussinessTypes'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterProvinces Model
*
* @property \App\Model\Table\MasterCountriesTable|\Cake\ORM\Association\BelongsTo $MasterCountries
* @property \App\Model\Table\MasterDistrictsTable|\Cake\ORM\Association\HasMany $MasterDistricts
* @property |\Cake\ORM\Association\HasMany $UserHomeplaces
*
* @method \App\Model\Entity\MasterProvince get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterProvince newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterProvince[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterProvince|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterProvince patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterProvince[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterProvince findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterProvincesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('master_provinces');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterCountries', [
'foreignKey' => 'master_country_id',
'joinType' => 'INNER'
]);
$this->hasMany('MasterDistricts', [
'foreignKey' => 'master_province_id'
]);
$this->hasMany('UserHomeplaces', [
'foreignKey' => 'master_province_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('province_code')
->allowEmpty('province_code');
$validator
->scalar('province_name_th')
->allowEmpty('province_name_th');
$validator
->scalar('province_name_en')
->allowEmpty('province_name_en');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['master_country_id'], 'MasterCountries'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
public static function defaultConnectionName()
{
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* MasterSections Model
*
* @property \App\Model\Table\MasterDepartmentsTable|\Cake\ORM\Association\BelongsTo $MasterDepartments
* @property \App\Model\Table\ArticleAccessesTable|\Cake\ORM\Association\HasMany $ArticleAccesses
*
* @method \App\Model\Entity\MasterSection get($primaryKey, $options = [])
* @method \App\Model\Entity\MasterSection newEntity($data = null, array $options = [])
* @method \App\Model\Entity\MasterSection[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\MasterSection|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\MasterSection patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\MasterSection[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\MasterSection findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class MasterSectionsTable extends Table {
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config) {
parent::initialize($config);
$this->setTable('master.master_sections');
$this->setDisplayField('section_name_th');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterDepartments', [
'foreignKey' => 'master_department_id'
]);
$this->hasMany('ArticleAccesses', [
'foreignKey' => 'master_section_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator) {
$validator
->allowEmpty('id', 'create');
$validator
->scalar('section_name_th')
->allowEmpty('section_name_th');
$validator
->scalar('section_name_en')
->allowEmpty('section_name_en');
$validator
->scalar('section_abbr_th')
->allowEmpty('section_abbr_th');
$validator
->scalar('section_abbr_en')
->allowEmpty('section_abbr_en');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules) {
$rules->add($rules->existsIn(['master_department_id'], 'MasterDepartments'));
return $rules;
}
/**
*
* Returns the database connection name to use by default.
* @author pakgon.Ltd
* @return string
*/
public static function defaultConnectionName() {
return 'db_master';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* SubjectEnrolls Model
*
* @property \App\Model\Table\SubjectsTable|\Cake\ORM\Association\BelongsTo $Subjects
* @property \App\Model\Table\UsersTable|\Cake\ORM\Association\BelongsTo $Users
* @property \App\Model\Table\MasterOrganizationsTable|\Cake\ORM\Association\BelongsTo $MasterOrganizations
*
* @method \App\Model\Entity\SubjectEnroll get($primaryKey, $options = [])
* @method \App\Model\Entity\SubjectEnroll newEntity($data = null, array $options = [])
* @method \App\Model\Entity\SubjectEnroll[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\SubjectEnroll|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\SubjectEnroll patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\SubjectEnroll[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\SubjectEnroll findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class SubjectEnrollsTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('education.subject_enrolls');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
//$this->belongsTo('Subjects', [
// 'foreignKey' => 'subject_id'
//]);
$this->belongsTo('Users', [
'foreignKey' => 'user_id'
]);
$this->belongsTo('MasterOrganizations', [
'foreignKey' => 'master_organization_id',
'joinType' => 'INNER'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('card_code')
->maxLength('card_code', 20)
->requirePresence('card_code', 'create')
->notEmpty('card_code');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('create_uid', 'create')
->notEmpty('create_uid');
$validator
->allowEmpty('update_uid');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
//$rules->add($rules->existsIn(['subject_id'], 'Subjects'));
$rules->add($rules->existsIn(['user_id'], 'Users'));
$rules->add($rules->existsIn(['master_organization_id'], 'MasterOrganizations'));
return $rules;
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* UserNames Model
*
* @property \App\Model\Table\FacultiesTable|\Cake\ORM\Association\BelongsTo $Faculties
* @property \App\Model\Table\RolesTable|\Cake\ORM\Association\BelongsTo $Roles
* @property \App\Model\Table\NamePrefixesTable|\Cake\ORM\Association\BelongsTo $NamePrefixes
*
* @method \App\Model\Entity\UserName get($primaryKey, $options = [])
* @method \App\Model\Entity\UserName newEntity($data = null, array $options = [])
* @method \App\Model\Entity\UserName[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\UserName|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\UserName patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\UserName[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\UserName findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class UserNamesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('user_names');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Faculties', [
'foreignKey' => 'faculty_id'
]);
$this->belongsTo('Roles', [
'foreignKey' => 'role_id'
]);
$this->belongsTo('NamePrefixes', [
'foreignKey' => 'name_prefix_id',
'joinType' => 'INNER'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->integer('id')
->allowEmpty('id', 'create');
$validator
->scalar('ref_code')
->allowEmpty('ref_code');
$validator
->scalar('username')
->requirePresence('username', 'create')
->notEmpty('username');
$validator
->scalar('password')
->requirePresence('password', 'create')
->notEmpty('password');
$validator
->scalar('first_name')
->requirePresence('first_name', 'create')
->notEmpty('first_name');
$validator
->scalar('last_name')
->requirePresence('last_name', 'create')
->notEmpty('last_name');
$validator
->email('email')
->allowEmpty('email');
$validator
->scalar('office_phone')
->allowEmpty('office_phone');
$validator
->scalar('mobile_phone')
->allowEmpty('mobile_phone');
$validator
->date('birth_date')
->allowEmpty('birth_date');
$validator
->scalar('address')
->allowEmpty('address');
$validator
->scalar('moo')
->allowEmpty('moo');
$validator
->scalar('road')
->allowEmpty('road');
$validator
->scalar('sub_district')
->allowEmpty('sub_district');
$validator
->scalar('district')
->allowEmpty('district');
$validator
->scalar('province')
->allowEmpty('province');
$validator
->scalar('zipcode')
->allowEmpty('zipcode');
$validator
->scalar('status')
->requirePresence('status', 'create')
->notEmpty('status');
$validator
->scalar('picture_path')
->allowEmpty('picture_path');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->isUnique(['username']));
$rules->add($rules->isUnique(['email']));
$rules->add($rules->existsIn(['faculty_id'], 'Faculties'));
$rules->add($rules->existsIn(['role_id'], 'Roles'));
$rules->add($rules->existsIn(['name_prefix_id'], 'NamePrefixes'));
return $rules;
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* UserPersonLists Model
*
* @property |\Cake\ORM\Association\BelongsTo $Users
* @property |\Cake\ORM\Association\BelongsTo $Organizes
* @property |\Cake\ORM\Association\BelongsTo $Depts
* @property |\Cake\ORM\Association\BelongsTo $Sections
* @property |\Cake\ORM\Association\BelongsTo $UserTypes
* @property |\Cake\ORM\Association\BelongsTo $MasterBusinessTypes
*
* @method \App\Model\Entity\UserProfile get($primaryKey, $options = [])
* @method \App\Model\Entity\UserProfile newEntity($data = null, array $options = [])
* @method \App\Model\Entity\UserProfile[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\UserProfile|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\UserProfile patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\UserProfile[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\UserProfile findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class UserPersonListsTable extends Table {
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config) {
parent::initialize($config);
$this->setTable('user_person_lists');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
//$this->belongsTo('MasterOrganizations', [
// 'foreignKey' => 'master_organization_id',
// 'joinType' => 'INNER'
//]);
$this->belongsTo('MasterDepartments', [
'foreignKey' => 'master_department_id'
]);
$this->belongsTo('MasterSections', [
'foreignKey' => 'master_section_id'
]);
//$this->belongsTo('MasterUserTypes', [
// 'foreignKey' => 'master_user_type_id'
//]);
$this->belongsTo('Users', [
'foreignKey' => 'user_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator) {
$validator
->allowEmpty('id', 'create');
$validator
->scalar('card_code')
->maxLength('card_code', 20)
->allowEmpty('card_code');
$validator
->scalar('first_name')
->maxLength('first_name', 50)
->allowEmpty('first_name');
$validator
->scalar('last_name')
->maxLength('last_name', 50)
->allowEmpty('last_name');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('create_uid', 'create')
->notEmpty('create_uid');
$validator
->allowEmpty('update_uid');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
//$rules->add($rules->existsIn(['master_organization_id'], 'MasterOrganizations'));
$rules->add($rules->existsIn(['master_department_id'], 'MasterDepartments'));
$rules->add($rules->existsIn(['master_section_id'], 'MasterSections'));
//$rules->add($rules->existsIn(['master_user_type_id'], 'MasterUserTypes'));
$rules->add($rules->existsIn(['user_id'], 'Users'));
return $rules;
}
/**
*
* Returns the database connection name to use by default.
* @author pakgon.Ltd
* @return string
*/
// public static function defaultConnectionName()
// {
// return 'core';
// }
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* UserPersonals Model
*
* @property \App\Model\Table\MasterPrefixesTable|\Cake\ORM\Association\BelongsTo $MasterPrefixes
* @property \App\Model\Table\UsersTable|\Cake\ORM\Association\BelongsTo $Users
*
* @method \App\Model\Entity\UserPersonal get($primaryKey, $options = [])
* @method \App\Model\Entity\UserPersonal newEntity($data = null, array $options = [])
* @method \App\Model\Entity\UserPersonal[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\UserPersonal|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\UserPersonal patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\UserPersonal[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\UserPersonal findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class UserPersonalsTable extends Table {
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config) {
parent::initialize($config);
$this->setTable('core.user_personals');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('MasterPrefixes', [
'foreignKey' => 'master_prefix_id'
]);
$this->belongsTo('Users', [
'foreignKey' => 'user_id'
]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator) {
$validator
->allowEmpty('id', 'create');
$validator
->scalar('person_card_no')
->requirePresence('person_card_no', 'create')
->notEmpty('person_card_no');
$validator
->scalar('firstname_th')
->allowEmpty('firstname_th');
$validator
->scalar('lastname_th')
->allowEmpty('lastname_th');
$validator
->scalar('firstname_en')
->allowEmpty('firstname_en');
$validator
->scalar('lastname_en')
->allowEmpty('lastname_en');
$validator
->scalar('gender')
->allowEmpty('gender');
$validator
->date('birthdate')
->allowEmpty('birthdate');
$validator
->scalar('moblie_no')
->allowEmpty('moblie_no');
$validator
->scalar('phone_no')
->allowEmpty('phone_no');
$validator
->email('email')
->allowEmpty('email');
$validator
->allowEmpty('created_by');
$validator
->allowEmpty('modified_by');
$validator
->scalar('blood_group')
->allowEmpty('blood_group');
$validator
->scalar('address')
->allowEmpty('address');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules) {
$rules->add($rules->isUnique(['email']));
$rules->add($rules->existsIn(['master_prefix_id'], 'MasterPrefixes'));
$rules->add($rules->existsIn(['user_id'], 'Users'));
return $rules;
}
/**
*
* Returns the database connection name to use by default.
* @author pakgon.Ltd
* @return string
*/
public static function defaultConnectionName() {
return 'core';
}
}
<?php
namespace App\Model\Table;
use Cake\ORM\Query;
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
/**
* UserProfiles Model
*
* @property |\Cake\ORM\Association\BelongsTo $Users
* @property |\Cake\ORM\Association\BelongsTo $Organizes
* @property |\Cake\ORM\Association\BelongsTo $Depts
* @property |\Cake\ORM\Association\BelongsTo $Sections
* @property |\Cake\ORM\Association\BelongsTo $UserTypes
* @property |\Cake\ORM\Association\BelongsTo $MasterBusinessTypes
* @property |\Cake\ORM\Association\BelongsTo $MasterOrganizationPositions
*
* @method \App\Model\Entity\UserProfile get($primaryKey, $options = [])
* @method \App\Model\Entity\UserProfile newEntity($data = null, array $options = [])
* @method \App\Model\Entity\UserProfile[] newEntities(array $data, array $options = [])
* @method \App\Model\Entity\UserProfile|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
* @method \App\Model\Entity\UserProfile patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method \App\Model\Entity\UserProfile[] patchEntities($entities, array $data, array $options = [])
* @method \App\Model\Entity\UserProfile findOrCreate($search, callable $callback = null, $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
class UserProfilesTable extends Table
{
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('user_profiles');
$this->setDisplayField('id');
$this->setPrimaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER'
]);
// $this->belongsTo('Organizes', [
// 'foreignKey' => 'organize_id'
// ]);
// $this->belongsTo('Depts', [
// 'foreignKey' => 'dept_id'
// ]);
// $this->belongsTo('Sections', [
// 'foreignKey' => 'section_id'
// ]);
// $this->belongsTo('UserTypes', [
// 'foreignKey' => 'user_type_id',
// 'joinType' => 'INNER'
// ]);
// $this->belongsTo('MasterBusinessTypes', [
// 'foreignKey' => 'master_business_type_id'
// ]);
// $this->belongsTo('MasterOrganizationPositions', [
// 'foreignKey' => 'master_organization_position_id'
// ]);
}
/**
* Default validation rules.
*
* @param \Cake\Validation\Validator $validator Validator instance.
* @return \Cake\Validation\Validator
*/
public function validationDefault(Validator $validator)
{
$validator
->allowEmpty('id', 'create');
$validator
->scalar('card_code')
->maxLength('card_code', 20)
->allowEmpty('card_code');
$validator
->scalar('img_path')
->maxLength('img_path', 255)
->allowEmpty('img_path');
$validator
->boolean('is_used')
->requirePresence('is_used', 'create')
->notEmpty('is_used');
$validator
->requirePresence('created_by', 'create')
->notEmpty('created_by');
$validator
->allowEmpty('modified_by');
$validator
->allowEmpty('position_org');
$validator
->allowEmpty('position_edu');
$validator
->date('enter_date')
->allowEmpty('enter_date');
$validator
->scalar('address')
->maxLength('address', 255)
->allowEmpty('address');
$validator
->scalar('phone_no')
->maxLength('phone_no', 30)
->allowEmpty('phone_no');
return $validator;
}
/**
* Returns a rules checker object that will be used for validating
* application integrity.
*
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
* @return \Cake\ORM\RulesChecker
*/
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->existsIn(['user_id'], 'Users'));
// $rules->add($rules->existsIn(['organize_id'], 'Organizes'));
// $rules->add($rules->existsIn(['dept_id'], 'Depts'));
// $rules->add($rules->existsIn(['section_id'], 'Sections'));
// $rules->add($rules->existsIn(['user_type_id'], 'UserTypes'));
// $rules->add($rules->existsIn(['master_business_type_id'], 'MasterBusinessTypes'));
// $rules->add($rules->existsIn(['master_organization_position_id'], 'MasterOrganizationPositions'));
return $rules;
}
/**
* Returns the database connection name to use by default.
*
* @return string
*/
//public static function defaultConnectionName()
//{
// return 'db_core';
//}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment