Skip to content

Instantly share code, notes, and snippets.

View jamband's full-sized avatar
👀
web browser

Tomoki Morita jamband

👀
web browser
View GitHub Profile
@jamband
jamband / console.php
Created July 16, 2012 04:50
Yii Framework: console command in module.
<?php
'commandMap' => array(
'deleteexpireduser' => array(
'class' => 'application.modules.user.commands.DeleteExpiredUserCommand',
),
),
@jamband
jamband / Register.php
Created July 14, 2012 03:20
ii Framework: label hint v2
<?php
class Register extends User
{
/**
* @var string パスワード(確認)
*/
public $verifyPassword;
/**
@jamband
jamband / Register.php
Created July 13, 2012 16:01
Yii Framework: label hint
<?php
/**
* Frontend Register class file.
*/
class Register extends User
{
...
public function attributeLabels()
@jamband
jamband / WordTest.php
Created June 16, 2012 05:02
Yii Framework: Functional test case.
<?php
class WordTest extends WebTestCase
{
public $fixtures = array(
'words' => 'Word',
'users' => 'User',
);
public function test_index()
@jamband
jamband / WordController.php
Created June 15, 2012 04:40
Yii Framework: Test case in Controller
<?php
/**
* Frontend WordController class file.
*/
class WordController extends Controller
{
/**
* @see CController::accessRules()
*/
<?php
class Word extends ActiveRecord
{
...
/**
* Gets all models.
* @param mixed $sort null sorting strings
* @param mixed $q null searching strings
* @return array pagination object and all models
*/
@jamband
jamband / MyFormatter.php
Last active October 3, 2015 06:58
Yii Framework: Extending CFormatter sample.
<?php
/**
* 1. /protected/components/MyFormatter.php を作成。CFormatter を extends する
* 2. format から始まる名前で独自のメソッドを追加
*/
class MyFormatter extends CFormatter
{
public function formatBold($val)
{
return '<b>' . $val . '</b>';
@jamband
jamband / LoginAttempt.php
Created April 12, 2012 17:32
Yii Framework: Test case in LoginAttemptTest.php
<?php
/**
* LoginAttempt class file.
*
* The followings are the available columns in table 'login_attempt':
* @property integer $id
* @property string $ip
* @property string $login
* @property integer $create_time
@jamband
jamband / TestCommand.php
Last active October 2, 2015 23:07
Yii Framework: TestCommand.php
<?php
class TestCommand extends CConsoleCommand
{
public function run()
{
$c = new CDbCriteria();
$model = new Hoge();
$model->name = 'test' . $model->count($c);
$model->save(false);
@jamband
jamband / LoginAttempt.php
Last active December 4, 2018 09:51
Yii Framework: Login Attempt
<?php
class LoginAttempt extends ActiveRecord
{
const LOGIN_ATTEMPT_LIMIT = 5; // ログイン試行回数のリミット
const BANNED_IP_EXPIRATION_TIME = '+1 hour'; // この場合は禁止されてから一時間経たないとログインできない
...
/**
* @see CActiveRecord::beforeSave()
*/