Skip to content

Instantly share code, notes, and snippets.

View JeffreyWay's full-sized avatar

Jeffrey Way JeffreyWay

View GitHub Profile
@JeffreyWay
JeffreyWay / laravel.js
Last active July 17, 2026 08:13
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@JeffreyWay
JeffreyWay / web.php
Created July 17, 2020 16:04
Array Filtering + Casting Demo
<?php
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('/names', function () {
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<?php
$books = [
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Episode 1: The Absolute Basics</title>
<script src="https://unpkg.com/vue@3"></script>
</head>
<body>
<div id="app">
<p>
@JeffreyWay
JeffreyWay / PjaxMiddleware.php
Last active April 4, 2026 17:18
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@JeffreyWay
JeffreyWay / index.php
Last active February 19, 2026 13:01
PHP for Beginners, Episode 10 - Separate Logic From the Template https://laracasts.com/series/php-for-beginners-2023-edition/episodes/10
<?php
$books = [
[
'name' => 'Do Androids Dream of Electric Sheep',
'author' => 'Philip K. Dick',
'releaseYear' => 1968,
'purchaseUrl' => 'http://example.com'
],
[
@JeffreyWay
JeffreyWay / BaseModel.php
Last active February 9, 2026 17:22
To make for clean and readable tests, do your mocking in a base model that your Eloquent models extend.
<?php
class BaseModel extends Eloquent {
public static function shouldReceive()
{
$repo = get_called_class() . 'RepositoryInterface';
$mock = Mockery::mock($repo);
App::instance($repo, $mock);
@JeffreyWay
JeffreyWay / homework-solution.php
Last active February 8, 2026 14:29
PHP For Beginners, Episode 5 - Conditionals and Booleans
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<h1>
<?= 'Hello World' ?>
</h1>
<x-layout>
<x-section>
<x-tabs active="First">
<x-tab name="First">
First content goes here.
</x-tab>
<x-tab name="Second">
Second content goes here.
</x-tab>
<div class="bg-gray-200 p-4 rounded block relative">
<h2 class="font-bold">
<a href="https://laracasts.com/discuss/channels/laravel">
Laravel
<span class="absolute inset-0"></span>
</a>
</h2>
<p class="mt-3">
A web application framework with expressive, elegant syntax.