Skip to content

Instantly share code, notes, and snippets.

View artemrogov's full-sized avatar
🎯
Focusing

Artem Rogov artemrogov

🎯
Focusing
View GitHub Profile
@artemrogov
artemrogov / extract.php
Created August 18, 2018 10:14
extract — Импортирует переменные из массива в текущую таблицу символов
/*
EXTR_OVERWRITE Если переменная с таким именем существует, она будет перезаписана.
EXTR_SKIP Если переменная с таким именем существует, ее текущее значение не будет перезаписано.
EXTR_PREFIX_SAME сли переменная с таким именем существует, к её имени будет добавлен префикс, определённый параметром prefix
EXTR_PREFIX_ALL Добавить префикс prefix ко всем именам переменных.
EXTR_PREFIX_INVALID Добавить префикс prefix только к некорректным/числовым именам переменных.
[
{
"Sellers": [
{
"id": "5b51d746949908c1fbc4925d",
"first_name": "Jean",
"last_name": "Hicks",
"picture": "http://placehold.it/32x32",
"email": "[email protected]",
"active": true,
@artemrogov
artemrogov / having.sql
Created June 23, 2018 16:04
having.sql
select first_name, last_name, second_name, count(*)
from customers
group by first_name,last_name, second_name
having count(*) < 2
order by first_name, last_name, second_name;
@artemrogov
artemrogov / inner_join.sql
Last active June 23, 2018 15:45
#естественное соединение таблиц продукты с атрибутами и их значениями
#естественное соединение таблиц продукты с атрибутами и их значениями:
select id_product,
name_product,
price,
code_product,
@artemrogov
artemrogov / CatProductsManyToMany
Created June 18, 2018 15:16
ManyToMany RelationShips Products vs CategoryProducts
class CreateTbPivotCatProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products_has_categories', function (Blueprint $table) {
@artemrogov
artemrogov / homestead-manual-install.md
Created June 13, 2018 13:12 — forked from idecardo/homestead-manual-install.md
Laravel Homestead Manual Installation

Getting Started

Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine. Read more...

Download

Download homestead box using this link:

@artemrogov
artemrogov / docker-documentation.txt
Created May 25, 2018 07:24
docker-documentation file help
docker build -t friendlyhello . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker image ls -a # List all images on this machine
@artemrogov
artemrogov / exception.php
Created May 19, 2018 14:22
simple example for exception
class GPS_Coord extends Exception{}
class OutputCoord extends Exception {}
class ErorrNullable extends Exception{}
function drawPoint($point){
if ($point!=0){
if (is_string($point)){
throw new GPS_Coord("Это строка!!", 200);
}
elseif($point > 500 && $point<10){
@artemrogov
artemrogov / exceptionPHP.php
Last active May 18, 2018 21:29
Exception for php
function isNum($num){
if ($num % 2 == 0){
throw new Exception("Ты не верно решил пример!!");
}
return $num;
}
try{
echo isNum(4);
}catch (Exception $a){
echo $a->getMessage();
@artemrogov
artemrogov / eloquent.php
Created May 18, 2018 14:07
Выражения ORM Eloquent
/*Eloquent выражения:
====================================================================
Связи, уникальные для каждого пользователя, связь модель магазин и продукт:*/
$result = $store->find(Auth::user()->id)->products()->create($request->all());