The City Bakery

I love the City Bakery, especially their peanut butter cookies.
Their burgers and wraps are good too.

I had the Jerk Chicken Wrap today. It was fantastic.

ワオ!と言っているユーザー

Tonkotsu-ramen

I am a burger person and so, rarely eat ramen. However, was starving today and decided to give my local ramen store a try.

ワオ!と言っているユーザー

Yuki

We have two dogs in our family. This is Yuki, four years old. She likes taking naps
on my wife's pillow.
#yuki

ワオ!と言っているユーザー

Japanese melon: Ibara King

My wife is at work and my dogs are getting groomed so I am at home, writing PHP and enjoying a slice of Ibara King.

The name Ibara King is a pun on the prefecture name Ibaraki. Sorry name but the fruit is delicious, it is sweet and has a nice solid texture. The Higo Green I had the other day was softer, more fragrant.

I give this one three stars too.

ワオ!と言っているユーザー

Japanese melon: Higo Green

Higo Green
When I wore a younger man's clothes, melons were a luxury. These days a whole melon starts at around 5USD.

I like green ones best - here is a picture of Higo Green, a melon farmed in Kumamoto. It was yummy, I give it three stars.
#foodInJapan

ワオ!と言っているユーザー

CakePHP3: Two sets of pagination for the same model

Say you want two sets of pagination against the same model, each with a different condition.

Here is how to do it, assuming we have a table called articles, and we want pagination for current articles and for past (expired) articles. In your controller, write this:


$this->paginate = [
'Articles' => [
'scope' => 'current_articles',
],
'PastArticles' => [
'scope' => 'past_articles',
],
];

TableRegistry::config('PastArticles', [
'className' => 'App\Model\Table\ArticlesTable',
'table' => 'articles',
'entityClass' => 'App\Model\Entity\Article',
]);

$currentArticles = $this->paginate(
$this->Articles->find('all', [
'scope' => 'current_articles'
])->where(['expiry >' => Time::now()])
);
$pastArticles = $this->paginate(
TableRegistry::getTableLocator()->get('PastArticles')->find('all', [
'scope' => 'past_articles'
])->where(['expiry <=' => Time::now()])
);

$this->set(compact('currentArticles','pastArticles'));


And in your view, do this:


$this->Paginator->options(['model' => 'Articles']);
echo $this->Paginator->first('<<');
echo $this->Paginator->prev('<');
echo $this->Paginator->numbers();
echo $this->Paginator->next('>');
echo $this->Paginator->last('>>');

$this->Paginator->options(['model' => 'PastArticles']);
echo $this->Paginator->first('<<');
echo $this->Paginator->prev('<');
echo $this->Paginator->numbers();
echo $this->Paginator->next('>');
echo $this->Paginator->last('>>');

#cakephp3

ワオ!と言っているユーザー

CakePHP3: Clear cache, including routing info


cd app/bin
./cake cache clear_all
#cakephp3

ワオ!と言っているユーザー

CakePHP3: Check if user browsing from iPad

Cake is built in with MobileDetect nowadays, so it is as simple as this:


<?php
use Mobile_Detect;
$mb = new Mobile_Detect;
if($mb->isIpad()){
echo "is ipad";
}else{
echo "is not ipad";
}


There are other handy methods such is isMobile(), isChrome() etc:
http://mobiledetect.net/
#cakephp3

ワオ!と言っているユーザー

CakePHP3: Fetch a particular column from all rows

Say we have the following data in a table called countries:

id country capitol
1 USA Washington DC
2 Japan Tokyo
3 United Kingdom London


And you want to fetch data like this:

['Washington DC', 'Tokyo', 'London']


Then do this:

$capitols = $this->countries
->find()
->extract('capitol')
->toArray();

#cakephp3

ワオ!と言っているユーザー

CakePHP3: Get the full URL of the current page

Method 1: Use the URL helper


$url = $this->Url->build([
"controller" => "Posts",
"action" => "search",
"?" => ["foo" => "bar"]
],true);


Method 2: Use the Router


use Cake\Routing\Router;

$url = Router::url([
'controller' => 'Posts',
'action' => 'search',
'?' => ['foo' => $bar]
], true);
#cakephp3

ワオ!と言っているユーザー

CakePHP3: Check if record exists

Here is a handy way to do it:

To check by primary key:


if ($this->Users->exists($id)) {
}


To find by specifying where clause:


if ($this->Users->exists(['email' => $email])) {
}


Much more convenient than using find('count').
#cakephp3

ワオ!と言っているユーザー

×
  • ブログルメンバーの方は下記のページからログインをお願いいたします。
    ログイン
  • まだブログルのメンバーでない方は下記のページから登録をお願いいたします。
    新規ユーザー登録へ