Skip to content

Instantly share code, notes, and snippets.

View DarkGhostHunter's full-sized avatar
👨‍💻
Hands full

Italo DarkGhostHunter

👨‍💻
Hands full
View GitHub Profile
<?php
namespace App\Http\Controllers;
use App\Template;
class TemplateController extends Controller
{
/**
* Create a new contract.
<?php
class SecureJSON
{
public $array;
public $key;
public function __construct(array $array)
{
@DarkGhostHunter
DarkGhostHunter / Request.php
Last active July 9, 2020 05:09
Container example
<?php
class ExampleController
{
/**
* The new way
*
* @param Transport $transport
* @param Package $package
* @param Weather $weather
@DarkGhostHunter
DarkGhostHunter / Container.php
Created July 9, 2020 04:44
Container class to pass through the next method.
<?php
class Container
{
protected $target;
protected $value;
public function __construct($target, $value)
{
$this->target = $target;
@DarkGhostHunter
DarkGhostHunter / Throttler.php
Last active February 10, 2023 10:58
A class that throttles it's target methods calls.
<?php
namespace App\Throttler;
use Illuminate\Cache\RateLimiter;
class Throttler
{
/**
* Target to rate limit.
@DarkGhostHunter
DarkGhostHunter / ThrottlesCalls.php
Last active June 2, 2020 04:15
Simple Trait to throttle method calls.
<?php
namespace App\Throttler;
trait ThrottlesCalls
{
/**
* Throttles the next method call.
*
* @param int $tries
@DarkGhostHunter
DarkGhostHunter / layout.blade.php
Created March 17, 2020 19:28
Main App Layout
<!doctype html>
<html lang="{{ config('app.locale') }}">
<head>
@include('web.layout.head')
</head>
<body>
<header>
@include('web.layout.header')
</header>
<main>
@DarkGhostHunter
DarkGhostHunter / Enumerate.php
Created March 13, 2020 20:33
A nice class that enumerates values
<?php
class Enumerate
{
/**
* Current state of the enumerated object.
*
* @var string
*/
protected $current;
@DarkGhostHunter
DarkGhostHunter / ShareAuthenticatedUser.php
Created January 14, 2020 15:38
Shares the Authenticated User in all views
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\Auth\Authenticatable;
class ShareAuthenticatedUser
{
@DarkGhostHunter
DarkGhostHunter / Transport.php
Last active November 11, 2022 05:26
An invokable class for route binding
<?php
namespace App\Http\Bindings;
class Transport
{
/**
* Resolve the route bind
*
* @param string $value