Skip to content

Instantly share code, notes, and snippets.

View elliotforbes's full-sized avatar
:octocat:

Elliot Forbes elliotforbes

:octocat:
View GitHub Profile
.list{
display: flex;
flex-wrap: wrap;
}
.list-item{
background-color: #eee;
display: flex;
color: white;
}
// phones and other small devices
@media (min-width: 34em) { … }
// tablets and phablets
@media (min-width: 48em) { … }
// large devices like desktops
@media (min-width: 62em) { … }
// for the big screened desktops
@media (min-width: 75em) { … }
php artisan make:middleware AdMiddleware
<?php
namespace App\Http\Middleware;
use Closure;
class AdMiddleware
{
/**
* Handle an incoming request.
*
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
// our new class.
\App\http\Middleware\AdMiddleware::class,
];
<?php
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
{!! Form::open(array('route' => 'queries.search’, 'class'=>'form navbar-form navbar-right searchform')) !!}
{!! Form::text('search', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Search for a tutorial...')) !!}
{!! Form::submit('Search',
array('class'=>'btn btn-default')) !!}
{!! Form::close() !!}
Route::resource('queries', 'QueryController');
public function search(Request $request)
{
// Gets the query string from our form submission
$query = Request::input('search');
// Returns an array of articles that have the query string located somewhere within
// our articles titles. Paginates them so we can break up lots of search results.
$articles = DB::table('articles')->where('title', 'LIKE', '%' . $query . '%')->paginate(10);
// returns a view and passes the view the list of articles and the original query.
return view('page.search', compact('articles', 'query'));
@if (count($articles) === 0)
... html showing no articles found
@elseif (count($articles) >= 1)
... print out results
@foreach($articles as $article)
print article
@endforeach
@endif