Skip to content

Instantly share code, notes, and snippets.

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

Oleksii Abrosymov amberlex78

🏠
Working from home
View GitHub Profile
@amberlex78
amberlex78 / highlighting_multi_level_menu.md
Created August 9, 2020 07:04
Highlighting multi-level menu items

Highlighting multi-level menu items

In a multi-level menu, you usually have to highlight the selected menu item and its parent element. This can be done based on the parent route.

<ul>
  <li>
    <a href="{{ route('admin.posts.index') }}"
       class="{{ Str::is('admin.posts.*', Route::currentRouteName()) ? 'is-active' : '' }}">
 Manage Posts
@amberlex78
amberlex78 / mail.php
Created October 3, 2015 07:12
Clean PHP code for mail
<?php
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=utf-8";
$headers[] = "From: Sender Name <sender@domain.com>";
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
<?php
// Поиск цены в строке
// Число типа: 27.30 или 33,56
preg_match('/[0-9]*[\.,]?[0-9]/', $text, $matches);
if (isset($matches[0])) {
$price = str_replace(',', '.', $matches[0]);
} else {
@amberlex78
amberlex78 / Tree.php
Last active August 29, 2015 14:26
Tree::flat2nested($arr);
<?php
/*
-----------------------------------
Reformat flat array to nested array
-----------------------------------
Array(
[2] => Array(
[id] => 2
[parent_id] => 0
@amberlex78
amberlex78 / many-to-many
Last active April 7, 2024 15:41
SQL many-to-many (users of task)
SELECT * FROM `tasks2users`
JOIN `users` ON (`tasks2users`.`user_id` = `users`.`id`)
JOIN `tasks` ON (`tasks2users`.`task_id` = `tasks`.`id`)