Skip to content

Instantly share code, notes, and snippets.

@ksenijakuc
ksenijakuc / authorization HTTP (php cgi)
Last active August 29, 2015 14:17
Передача $_SERVER['PHP_AUTH_PW'] и $_SERVER['PHP_AUTH_USER'] в GET
<IfModule mod_rewrite.c>
RewriteCond %{HTTP:Authorization} ^Basic.*
RewriteRule (.*) 1c_exchange.php?authorization=%{HTTP:Authorization} [QSA,L]
</IfModule>
@ksenijakuc
ksenijakuc / laravel-authors-with-general-film.php
Last active March 23, 2016 06:16
laravel orm query: get authors with one general film (films belongsTo authors)
<php
// table authors: id, name
// table films: id, name, general(boolean), author_id
Authors::leftJoin('films as general_film', function ($q) {
$q->on('authors.id', '=', 'general_film.author_id')
->on('general_film.id', '=',
DB::raw('(select id from films WHERE author_id = authors.id ORDER BY general DESC LIMIT 1)'));
});