Skip to content

Instantly share code, notes, and snippets.

View thermonuclear's full-sized avatar
🏠
Working from home

Anatoly Smilik thermonuclear

🏠
Working from home
View GitHub Profile
@thermonuclear
thermonuclear / Support.php
Created May 30, 2024 14:05
Laravel пример mailable класса
<?php
namespace App\Mail;
use App\Sources\LogEventSource;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Http\UploadedFile;
use Illuminate\Mail\Mailables\Attachment;
@thermonuclear
thermonuclear / Mail365Transport.php
Created May 30, 2024 14:04
Laravel кастомный транспорт для отправки email
<?php
namespace App\Mail;
use Exception;
use Illuminate\Support\Facades\Log;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Mailer\Transport\AbstractTransport;
use Symfony\Component\Mime\MessageConverter;
use App\Mail\mail365\Mail365;
@thermonuclear
thermonuclear / SupportController.php
Created May 30, 2024 14:02
Laravel Контроллер отправки писем в техподдержку
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Mail\Support;
use App\Sources\LogEventSource;
use App\Sources\SettingSource;
use App\Sources\RefSupportThemeSource;
use Exception;
@thermonuclear
thermonuclear / HasPublicApiAccess.php
Created May 30, 2024 13:48
Laravel пример middleware
<?php
namespace App\Http\Middleware;
use App\Services\PublicApiService;
use Closure;
use Illuminate\Http\Request;
class HasPublicApiAccess
{
@thermonuclear
thermonuclear / SettingsController.php
Created May 30, 2024 13:47
Laravel контроллер с комментариями для swagger
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Sources\LogEventSource;
use App\Sources\SettingSource;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@thermonuclear
thermonuclear / ws_swoole.php
Last active May 30, 2024 13:33
Laravel веб-сокет сервер
<?php
namespace App\Console\Commands;
use App\Helpers\Common;
use App\Models\OnlineUser;
use App\Websocket\Game;
use App\Websocket\Invite;
use App\Websocket\Question;
use Exception;
@thermonuclear
thermonuclear / GrowBrancheSource.php
Last active May 30, 2024 13:33
Laravel Класс для работы с данными
<?php
namespace App\Sources;
use App\Models\GrowBranche;
use Illuminate\Support\Facades\DB;
class GrowBrancheSource
{
public static int $maxBranches = 3;
@thermonuclear
thermonuclear / OnlineUser.php
Last active May 30, 2024 13:34
Laravel Пример Eloquent модели
<?php
namespace App\Models;
use App\Sources\GrowBrancheSource;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
@thermonuclear
thermonuclear / rtk.sql
Last active June 3, 2022 16:27
Когда на собеседовании спрашивают: использовали ли JOIN, UNION, GROUP BY, вложенные запросы )))
SELECT `clients`.`user_id`, `clients`.`id` AS `client_id`, `clients`.`email` AS `client_email`, `clients`.`name` AS `client_name`,
`views0`.`views` AS `views0`, `views1`.`views` AS `views1`, `views2`.`views` AS `views2`, `views3`.`views` AS `views3`,
`rtk_promo_teachers`.`id`, `rtk_promo_teachers`.`created_at`, `rtk_promo_teachers`.`creative_file`, `rtk_users`.`id_user`, `rtk_users`.`id_school`
FROM `rtk_promo_teachers` JOIN `clients` ON (`clients`.`user_id` = `rtk_promo_teachers`.`user_id`)
JOIN `rtk_users` ON (`rtk_users`.`user_id` = `rtk_promo_teachers`.`user_id`)
LEFT JOIN (SELECT `promo_users`.`teacher_user_id`, COUNT(*) as views FROM `lesson_views`
JOIN `lessons` ON (`lessons`.`id` = `lesson_views`.`lesson_id`)
JOIN `lessons_set_to_lesson` ON (`lessons_set_to_lesson`.`lesson_id` = `lessons`.`parent_id`)
JOIN ((SELECT `rtk_promo_teachers`.`user_id` AS `teacher_user_id`, `rtk_promo_teachers`.`user_id` FROM `rtk_promo_teachers`)
UNION (
# 1.1 SQL определение таблицы exch_quotes_archive
CREATE TABLE `exch_quotes_archive` (
`exchange_id` int(11) unsigned NOT NULL COMMENT 'идентификатор биржи',
`bond_id` int(11) unsigned NOT NULL COMMENT 'идентификатор облигации',
`trading_date` DATE NOT NULL COMMENT 'дата торгов на бирже',
`bid` decimal(8, 4) COMMENT 'цена спроса, дробное число, цена в долях от номинала бумаги, signed, бОльшая часть значений как правило лежит диапазоне [-0.01;2], но возможны любые числа; null значит, что данные на дату отсутствуют',
`ask` decimal(8, 4) COMMENT 'цена продажи, те же характеристики, что у bid',
UNIQUE KEY `pk1` (`exchange_id`, `bond_id`, `trading_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='архив цен облигаций';