Skip to content

Instantly share code, notes, and snippets.

View thyseus's full-sized avatar
💭
Linux Rules

Herbert Maschke thyseus

💭
Linux Rules
  • Leipzig, Germany
View GitHub Profile
foreach (Yii::$app->session->getAllFlashes() as $message):; ?>
<?php
if ($message) {
if (is_array($message))
echo \kartik\widgets\Growl::widget([
'type' => (!empty($message['type'])) ? $message['type'] : 'danger',
'title' => (!empty($message['title'])) ? $message['title'] : 'Title Not Set!',
'icon' => (!empty($message['icon'])) ? $message['icon'] : 'fa fa-info',
'body' => (!empty($message['message'])) ? $message['message'] : 'Message Not Set!',
'showSeparator' => true,
Rätsel für Anfänger:
$a = false;
$b = true;
$c = $a or $b;
echo $c;
Rätsel für fortgeschrittene:
floor((0.1+0.7)*10);
(Lösung: floor(bcadd(0.1, 0.7, 1) * 10); )
User::find()->where('id != 1')->andWhere(['or', ['>', 'age', 40], ['<', 'age', 20]])->all();
"SELECT * FROM `users` WHERE (id != 1) AND ((`age` > :qp0) OR (`age` < :qp1))"
repositories": [
{
"type": "vcs",
"url": "https://github.com/thyseus/yii2-user"
},
{
"type": "vcs",
"url": "https://github.com/thyseus/yii2-audit"
}
],
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
],
// if you're using datetime instead of UNIX timestamp:
```php
if ($attribute) {
if($attribute->type != '') {
$super[Yii::t('app', $attribute->type)][] = Yii::t('app', $attribute->title);
} else {
$super[Yii::t('app', 'Allgemein')][] = Yii::t('app', $attribute->title);
}
}
Wie kann ich das besser machen?
```php
if (isset(Yii::$app->user)
&& isset(Yii::$app->user->identity)
&& isset(Yii::$app->user->identity->profile)
&& isset(Yii::$app->user->identity->profile->language)
) {
$language = Yii::$app->user->identity->profile->language;
$shop_id = 246,
$sql = '';
if (($handle = fopen("DATEI.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$sql = sprintf('insert into ratings (comment, shop_id, score, import_date, rating_date)
values("%s", "%s", "%s", "%s", "%s")',
In a view file i got:
```php
<?= Yii::t('app', '<i class="fa fa-download text-orange" aria-hidden="true"></i> <span class="productdownloads ml5">' . ($product->download_count > 0 ? $product->download_count : 0) . ' ' . Yii::t('app', 'Downloads') . '</span>'); ?>
```
Of course. This is WRONG. I know. But yii/extract should handle it... - anyway, it leads to this error:
```
Extracting messages from /var/www/html/hydra/views/products/view.php...
```php
class ReminderCest
{
public function _before(UnitTester $I)
{
}
public function _after(UnitTester $I)
{
}