This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET parameter | |
request()->query->remove('key'); | |
POST parameter | |
request()->request->remove('key'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz | |
sudo tar -xzf postman.tar.gz -C /opt | |
rm postman.tar.gz | |
sudo ln -s /opt/Postman/Postman /usr/bin/postman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is example how to return a relationship instance in laravel if u have some logic to get it or troubles | |
public function user() | |
{ | |
$id = ///some code to get $id | |
return $this->hasOne(User::class, 'id', 'id') // this just for new hasOne instance | |
->orWhere('id', $id); //get your niddle instanse | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Client model | |
private $notSaleSections = ['ТПМ-УПП', 'ТПМ-МДФ']; | |
public function saleParams() | |
{ | |
return $this->hasMany(ClientParameter::class, 'customer', 'id') | |
->whereHas('param', function ($q) { | |
$q->where('section', null); | |
foreach ($this->notSaleSections as $s){ | |
$q->orWhere('section', '!=', $s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Kernel | |
'permission' => \App\Http\Middleware\Permissions::class, | |
//Middleware\Permissions | |
public function handle($request, Closure $next, $permission = '') | |
{ | |
if (!$request->user() || !$request->user()->hasPermission($permission)) { | |
return redirect('/'); | |
} | |
return $next($request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo npm --global install [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -sSL https://raw.githubusercontent.com/DefaultValue/ubuntu_post_install_scripts/master/ubuntu_18.04.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use App\Permission; | |
use Cache; | |
use Illuminate\Contracts\Auth\Access\Gate as GateContract; | |
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$products = null; | |
Category::whereId($category_id)->with([ | |
'products' => function ($q) use (&$products, $search) { | |
$products = $q->where('active', true) | |
->search($search) //Scope | |
->get() | |
->unique(); | |
}, | |
'childrens.products' => function ($q) use (&$products, $search) { |
NewerOlder