Skip to content

Instantly share code, notes, and snippets.

@deleugpn
deleugpn / CrudController.php
Last active July 7, 2016 13:56
Dynamic Dependency Injection - MAKE SURE YOUR MODEL IMPLEMENTS ModelInterface!!
<?php
namespace App\Http\Controllers;
use App\ModelInterface;
use Illuminate\Http\Request;
use App\Http\Requests;
class CrudController extends Controller {
@deleugpn
deleugpn / DuskServeCommand.php
Last active April 27, 2024 15:04
Run php artisan serve before running php artisan dusk in a single console command.
<?php
namespace App\Console\Commands;
use RuntimeException;
use Laravel\Dusk\Console\DuskCommand;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;
class DuskServeCommand extends DuskCommand {
@deleugpn
deleugpn / DuskAssertBrowserEnvironment
Last active May 14, 2017 22:34
Allow Dusk to assert environment matches Browser environment
<?php
namespace Tests;
use PHPUnit\Framework\Assert as PHPUnit;
use Laravel\Dusk\Browser as DuskBrowser;
class Browser extends DuskBrowser {
/**
<?php
/**
* Display a listing of the resource.
*
* @param User $user
* @return \Illuminate\Http\Response
*/
public function index(User $user)
{
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class UsersResource extends Resource
{
/**
* Transform the resource into an array.
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class PostsResource extends Resource
{
/**
* Transform the resource into an array.
# .bashrc
# User specific aliases and functions
[ -r /etc/bashrc ] && source /etc/bashrc
[ -r /etc/bash_completion ] && source /etc/bash_completion
[ -r ~/.git-completion.bash ] && source ~/.git-completion.bash
[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh
[ -r /usr/local/rvm/scripts/rvm ] && source /usr/local/rvm/scripts/rvm
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see the current branch in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
<?php
namespace App;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process as SymfonyProcess;
class Process
{
public function run($command, $directory = null)