Skip to content

Instantly share code, notes, and snippets.

View inxilpro's full-sized avatar

Chris Morrell inxilpro

View GitHub Profile
function showForm(Request $request) {
$request->session()->now('status-danger', 'There was an error!');
}
// Or ...
function processForm(Request $request) {
if ($failed_for_some_reason) {
return redirect()->back()->flash('status-danger', 'Oops! There was an error.');
}
<a href="https://www.nachi.org/verify.php?nachiid=NACHI97010103" target="_blank"><img src="https://www.nachi.org/webseals/seal-t.gif?nachiid=NACHI97010103" width="98" height="102" alt="Certified by the International Association of Certified Home Inspectors" border="0" /></a>
@inxilpro
inxilpro / CmsController.php
Created December 28, 2016 16:09
General thoughts
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class CmsController extends Controller
{
public function index()
{
<?php
$key = '[[ KEY ]]';
$userData = [
'avatarURL' => $user->avatarURL,
'email' => $user->email,
'id' => $user->id,
'name' => $user->name
]);
@inxilpro
inxilpro / webpack.config.js
Last active June 17, 2017 18:34
Using ts-loader
const babelOpts = {
'presets': ['react', 'es2015', 'stage-0'],
'plugins': ['syntax-dynamic-import'],
};
const config = {};
config.module = {
rules: [
{
<?php
class ConvertLineEndingsToCRLF
{
public function handle($request, Closure $next)
{
$response = $next($request);
return $response->setContent(
str_replace("\n", "\r\n", $response->getContent())
);
<?php
class Foobar
{
function setFoo($foo)
{
$this->foo = $foo;
}
function setBar($bar)
<?php
// these are the same…
public function create(array $attributes = [])
{
$instance = $this->newModelInstance($attributes);
$instance->save();
return $instance;
}
@inxilpro
inxilpro / routes.php
Last active September 29, 2017 14:13
Laravel "was()" concept
<?php
// Redirect /bar to /foo
Route::get('/foo', 'FooController')->was('/bar');
// Redirect /my-dashboard to /account/dashboard
// It seems like 'was' should always be absolute, even in a group
Route::group(['prefix' => 'account'], function() {
Route::get('/dashboard', [
'as' => 'account.dashboard',
import cx from 'classnames';
const defaultPrefix = 'ais';
let classMapper = className => className;
const defaultFormatter = (block, elements) => ({
className: cx(
elements
.filter(element => element !== undefined && element !== false)