Skip to content

Instantly share code, notes, and snippets.

View nsanden's full-sized avatar

Nate Sanden nsanden

View GitHub Profile
public function rules()
{
return [
// the name, email, subject and body attributes are required
[['name', 'email', 'subject', 'body'], 'required'],
// the email attribute should be a valid email address
['email', 'email'],
];
}
public function rules()
{
return [
['username', 'required'],
['username', 'unique', 'message' => 'This username has already been taken.'],
['username', 'string', 'min' => 2, 'max' => 255],
['email', 'required'],
['email', 'email'],
['email', 'unique', 'message' => 'This email address has already been taken.'],
$transes = (new \yii\db\Query())
->select('DATE_FORMAT(FROM_UNIXTIME(`created`), "%M %Y") as `dates`, SUM(amount) AS amount, SUM(fee) AS fee, SUM(net) AS net, SUM(IF(`amount`< 0, `amount`, 0 )) AS pay_out')
->from('tbl_transaction_newest')
->groupBy('`dates`')
->limit(1000)
->orderBy('created')
->all();
$accordian = [
'General Configuration' => [
'Timezone' => 'If you plan on using the Facebook Direct (easy) export option you should <a href="' . Yii::$app->urlManager->createUrl('setting/update') . '">specify your timezone</a> in Postradamus so your posts get scheduled to Facebook at the correct times.',
'Time and Date Format' => 'You can setup your own <a href="' . Yii::$app->urlManager->createUrl('setting/update') . '">time and date format</a> for Postradamus to use any time it displays a time or date. Right now, your times and dates will look like this: <i>' . date(Yii::$app->postradamus->get_user_date_format()) . '</i>',
],
'Working with Content' => [
'Ways to Find Content' => [
'Find on Web' => [
'Facebook' => [
'My Pages' => 'Find content on the Facebook pages you manage. This can be really useful if you want to find fan content.',
$accordian = [
'General Configuration|This is a description that would show before the accordion group below.' => [
'Timezone' => 'Example here',
'Time and Date Format' => 'Example here',
],
];
<?php
/* Searches pinterest (screen scrape) for photos */
public function search($search_params)
{
try {
$url = 'http://www.pinterest.com/search/pins/?q=' . urlencode($search_params['search_keywords']);
$html = file_get_contents($url);
} catch (\Exception $e) {
$this->message->set_message("Could not load the Pinterest search page. Please try again later." . "\n\n". $e->getMessage(), Message::MSG_TYPE_ERROR);
exit;
try {
if ( !$session->validate() ) {
$session = null;
}
} catch ( Exception $e ) {
// catch any exceptions
$session = null;
echo $e->getMessage();
}
<?php
class Test {
private $_testMethodArray;
public function testDeleteFromMethodArray()
{
$this->testMethodArray();
unset($this->testMethodArray()[0]);
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/**
* @var yii\web\View $this
* @var common\models\cList $model
*/
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>