Example 1
”`html
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<i class="icon-bell2"></i>
<span class="visible-xs-inline-block position-right">Activity</span>
<span v-if="notifications.length > 0" class="status-mark border-pink-300"></span>
</a>
Example 1
<template>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<i class="icon-bell2"></i>
<span class="visible-xs-inline-block position-right">Activity</span>
<span v-if="notifications.length > 0" class="status-mark border-pink-300"></span>
</a>
<div class="dropdown-menu dropdown-content">
<div class="dropdown-content-heading">
Activity
<ul class="icons-list">
<li @click="readAll()"><a href="#"><i class="icon-menu7"></i></a></li>
</ul>
</div>
<ul class="media-list dropdown-content-body width-350" v-if="notifications.length > 0">
<notification v-for="notification in notifications">
<a href="#">{{ notification.target_id }}</a> already parsed
<template slot="time">4 minutes</template>
</notification>
</ul>
<ul class="media-list dropdown-content-body width-350" v-else>
No activity
</ul>
</div>
</li>
</template>
<script>
export default {
methods: {
readAll: function () {
axios.post('/notes/readed')
.then(function (response) {
this.notifications = [];
}.bind(this))
.catch(function (error) {
console.log(error);
});
},
},
data() {
return {
notifications: []
}
},
mounted() {
axios.get('/notes')
.then(function (response) {
this.notifications = response.data;
}.bind(this))
.catch(function (error) {
console.log(error);
});
Echo.private('App.User.' + window.Laravel.userId)
.notification((notification) => {
console.log(notification);
this.notifications.push(notification);
});
}
}
</script>
Example 2
<template>
<div class="target-create-pane">
<div class="form-group">
<label class="control-label col-lg-2">Site ID</label>
<div class="col-lg-10">
<input name="id" type="text" v-model="site_id" @blur="blured()" class="form-control">
</div>
</div>
<div class="tabbable tab-content-bordered" v-if="groups.length > 0">
<ul class="nav nav-tabs nav-tabs-highlight">
<li class="active"><a href="#groups" data-toggle="tab" aria-expanded="true">Groups</a></li>
<li class=""><a href="#friends" @click="loadFriends()" data-toggle="tab"
aria-expanded="false">Friends</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane has-padding active" id="groups">
<table class="table target-create-table table-condensed">
<thead>
<tr>
<th width="3%">Follow</th>
<th>Group</th>
<th>Screen Name</th>
<th>Public</th>
</tr>
</thead>
<tbody>
<tr v-for="group in groups">
<td><input :id="group.id" type="checkbox" :value="'-' + group.id" name="groups[]"></td>
<td>
<a href="" target="_blank">
<img :src="group.photo_50" width="30" class="group-photo">
</a>
<label :for="group.id">{{ group.name }}</label>
</td>
<td>{{ group.screen_name }}</td>
<td v-if="group.is_closed == 0">Yes</td>
<td v-else>No</td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane has-padding" id="friends">
<table class="table target-create-table table-condensed">
<thead>
<tr>
<th width="3%">Follow</th>
<th>Friend</th>
<th>Screen Name</th>
</tr>
</thead>
<tbody>
<tr v-for="friend in friends">
<td><input :id="friend.id" type="checkbox" :value="friend.id" name="friends[]"></td>
<td>
<a href="" target="_blank">
<img :src="friend.photo_50" width="30" class="group-photo">
</a>
<label :for="friend.id">{{ friend.first_name }} {{ friend.last_name }}</label>
</td>
<td>{{ friend.domain }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="text-right">
<button type="submit" :disabled="submitDisabled" class="btn btn-primary">Save
<i class="icon-arrow-right14 position-right"></i></button>
</div>
</div>
</template>
<script>
export default {
methods: {
loadFriends: function () {
if (this.friends.length == 0) {
axios.post('/friends', {
site_id: this.site_id,
})
.then(function (response) {
if (response.data) {
this.friends = response.data;
this.submitDisabled = false;
}
}.bind(this))
.catch(function (error) {
console.log(error);
});
}
},
loadGroups: function () {
axios.post('/groups', {
site_id: this.site_id,
})
.then(function (response) {
if (response.data) {
this.groups = response.data;
this.submitDisabled = false;
}
}.bind(this))
.catch(function (error) {
console.log(error);
});
},
blured: function () {
this.groups = [];
this.friends = [];
this.loadGroups();
}
},
data() {
return {
friends: [],
groups: [],
site_id: 9999999,
submitDisabled: true
}
},
mounted() {}
}
</script>
git config receive.denycurrentbranch ignore
vi .git/hooks/post-receive
#!/bin/bash
cd ../
env -i git reset --hard
chmod +x .git/hooks/post-receive
git diff --name-status SHA1 SHA2 | cut -f2
git config receive.denycurrentbranch ignore
vi .git/hooks/post-receive
#!/bin/bash
cd ../
env -i git reset --hard
chmod +x .git/hooks/post-receive
git diff --name-status SHA1 SHA2 | cut -f2
”`php
$this->products()
->select('category_id',
DB::raw('count(*) as total'))
->groupBy('category_id')
->get();
Task::first();
Task::all();
Task::get();
$this->products()
->select('category_id',
DB::raw('count(*) as total'))
->groupBy('category_id')
->get();
Task::first();
Task::all();
Task::get();
Task::pluck('body');
Task::where('disabled', 1);
Task::selectRaw('year(created_at) year, monthname(created_at) month, count(*) active')->group_by('year', 'month')->get();
Source::leftJoin('site_target_sources', 'site_sources.id', '=', 'site_target_sources.source_id')
->leftJoin('site_targets', 'site_targets.id', '=', 'site_target_sources.target_id')
->where('site_targets.entity_id', $entity->id)
->groupBy('site_sources.id')
->get(['site_sources.*']);
#############################
# PRIMARY KEY
############################
public $primaryKey = 'admin_id';
public $increments = false;
#############################
# RELADTIONS
############################
public function comments()
{
return $this->hasMany('App\Comment');
}
public function user()
{
return $this->belongsTo('App\User');
}
public function phone()
{
return $this->hasOne('App\Phone');
}
#############################
# SCOPES
############################
// ------------
Task::incomplete();
public static function incomplete(){
return static::where('completed', 0)->get();
}
// ------------
Task::incomplete()->where('other', 1)->get();
public function scopeIncomplete($query){
return $query->where('completed', 0);
}
Folders should be normal “755” and files, “644”
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Snippets
”`php // dates Carbon::parse($createdAt)->addSeconds($this->expires)->isPast(); // check if expired
// token
Folders should be normal “755” and files, “644”
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
Snippets
// dates
Carbon::parse($createdAt)->addSeconds($this->expires)->isPast(); // check if expired
// token
$token = app('auth.password.broker')->createToken($user); // create token manually
// optional
optional($user)->name
”`bash
// Phpunit
./vendor/bin/phpunit
php artisan make:test CategoryTest --unit
// Scaffolding
php artisan make:model Post -m
php artisan make:seed PostTableSeed
// Phpunit
./vendor/bin/phpunit
php artisan make:test CategoryTest --unit
// Scaffolding
php artisan make:model Post -m
php artisan make:seed PostTableSeed
php artisan migrate:refresh --seed
php artisan make:controller PostController --model=Model\\Site\\Post
php artisan view:clear
// Dusk
composer require laravel/dusk
composer require barryvdh/laravel-ide-helper
Add to file app/config/app.php in Application Service Providers section
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Enable in (config/ide-helper.php)
'include_fluent' => true,
'include_helpers' => true,
Then
composer require barryvdh/laravel-ide-helper
Add to file app/config/app.php in Application Service Providers section
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Enable in (config/ide-helper.php)
'include_fluent' => true,
'include_helpers' => true,
Then
php artisan ide-helper:generate
php artisan ide-helper:meta
php artisan ide-helper:models
Script to composer.json
"scripts":{
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"php artisan optimize"
]
},
Useful tool apidoc. Setup:
apt update
apt nodejs
apt install nodejs-legacy
apt install npm
npm install apidoc -g
Now check with command apidoc -h.
If everything is alright:
Useful tool apidoc. Setup:
apt update
apt nodejs
apt install nodejs-legacy
apt install npm
npm install apidoc -g
Now check with command apidoc -h.
If everything is alright:
apidoc -i app/Http/Controllers/ -o ~/Projects/theproject-docs
php yii migrate/create create_user_table
php yii migrate/up
Yii::$app->request->baseUrl
Url::toRoute
$query->from('given t')
->leftJoin('given_product as rp','t.id = rp.issuance_id')
->leftJoin('product as p','p.id = rp.product_id')
->where(['p.status'=>Product::STATUS_GIVEN]);
SET FOREIGN_KEY_CHECKS = 0;
php yii migrate/create create_user_table
php yii migrate/up
Yii::$app->request->baseUrl
Url::toRoute
$query->from('given t')
->leftJoin('given_product as rp','t.id = rp.issuance_id')
->leftJoin('product as p','p.id = rp.product_id')
->where(['p.status'=>Product::STATUS_GIVEN]);
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE table1;
SET FOREIGN_KEY_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE article;
TRUNCATE brand;
TRUNCATE category;
SET FOREIGN_KEY_CHECKS = 1;