Skip to content

Instantly share code, notes, and snippets.

Laracasts laracasts

Block or report user

Report or block laracasts

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ApiTester.php
<?php
use Faker\Factory as Faker;
abstract class ApiTester extends TestCase {
/**
* @var int
*/
protected $times = 1;
View gist:99535e8db4298056b76d
<?= 'Add your Wii U username below'; ?>
View ex.php
<?php
// ...
public function store(RegistrationForm $form)
{
$form->validate(); // throws exception if fails
// save stuff
}
@laracasts
laracasts / codeception-ex.php
Last active Aug 29, 2015
I want an acceptance test for an Artisan command that generates some files with boilerplate. However, this command is part of a Composer package. I'm trying to figure out the best way to actually call Artisan from the package. Right now, I'm just assuming the framework and doing ../../../artisan. Is there an alternative/better way that you'd sug…
View codeception-ex.php
<?php
$saveDir = './tests/acceptance/tmp';
$stubDir = './tests/acceptance/stubs';
$commandToGenerate = 'FooCommand';
$I = new AcceptanceTester($scenario);
$I->wantTo('generate a command and handler class');
// Is there a better way to call the Artisan command? Without having to expect the framework and do ../../../?
View ex.php
/**
* Destroy the user's session (logout).
*
* @return Response
*/
public function destroy()
{
Auth::logout();
flash()->info('You are now logged out.');
@laracasts
laracasts / ex.php
Last active Aug 29, 2015
Working on integration testing helper for PHPUnit.
View ex.php
<?php
class ExampleTest extends IntegrationTest
{
/** test */
public function it_verifies_that_pages_load_properly()
{
$this->visit('/');
}
View CommandBus.php
<?php
// ...
/**
* Register a decorator for the command bus.
*
* @param string $decorator
* @return CommandBus
*/
View gist:7628742
@mixin linear-gradient($options...) {
background: -webkit-linear-gradient($details);
background: -moz-linear-gradient($details);
background: linear-gradient($details);
}
.foo {
@include linear-gradient(top, red, green);
}
@laracasts
laracasts / ex.php
Last active Jan 27, 2016
So you want to allow one user to "follow" another user (like Twitter-style). Using Laravel and Eloquent, what's your preference?
View ex.php
<?php
// Option 1: the follow method immediately references the relationship and saves it.
class User extends Eloquent {
public function follows()
{
return $this->belongsToMany(self::class, 'follows', 'follower_id', 'followed_id');
}
@laracasts
laracasts / gulpfile.js
Last active May 3, 2017
Example Laravel-specific Gulpfile from Laracasts.com
View gulpfile.js
var gulp = require('gulp');
var gutil = require('gulp-util');
var notify = require('gulp-notify');
var sass = require('gulp-ruby-sass');
var autoprefix = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css')
var coffee = require('gulp-coffee');
var exec = require('child_process').exec;
var sys = require('sys');
You can’t perform that action at this time.