public function user()
{
return $this->belongsTo(User::class);
}
Post::with('user')->orderBy('publish_at', 'desc')->get();
$posts = DB::table('posts')->select(DB::raw('posts.*, users.username'))
->join('users', 'posts.user_id', '=', 'users.id')
->orderBy('publish_at', 'desc')->get();
<module: (?!test)\w+>/<controller: \w+ >
# RewriteEngine
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Редирект на страницу без многократных /.
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]
# Убираем несколько слешей в урле
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
# Убираем последний слеш в урле
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} (/+)$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
# Редирект со строчных букв на прописные
# Необходимо в VirtualHost добавить RewriteMap lc int:tolower
# RewriteCond %{REQUEST_URI} [A-Z]
# RewriteRule ^(.*)$ /${lc:$1} [R=301,L]
# Блокируем рефер спам
RewriteCond %{HTTP_REFERER} simple-share-buttons\.com [NC]
RewriteRule .* – [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
#в случае index.php|htm|html:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTPS/
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]
</IfModule>
Content-Disposition: inline;filename=somefile.ext
Content-Disposition: attachment;filename=somefile.ext