Skip to content

Instantly share code, notes, and snippets.

@laracasts
laracasts / StatusRepository.php
Last active May 19, 2018 15:11
Integration Testing Repositories That Use Eloquent (with Codeception)
<?php namespace Larabook\Statuses;
use Larabook\Users\User;
class StatusRepository {
/**
* Get all statuses associated with a user.
*
* @param User $user
@laracasts
laracasts / MailTestCase.php
Created June 14, 2014 22:35
Use Mailcatcher to test email.
<?php
use GuzzleHttp\Message\Response;
class MailTestCase extends TestCase {
protected $mailcatcher;
function __construct()
{
@laracasts
laracasts / test.php
Last active July 10, 2018 16:33
Transactions for functional/integration tests.
<?php
class ExampleTest extends TestCase {
public function setUp()
{
parent::setUp();
DB::beginTransaction();
}
@laracasts
laracasts / pivot-generator.php
Last active September 14, 2018 10:15
Artisan Pivot Migration Generator
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
class PivotMigrationMakeCommand extends GeneratorCommand
{
@laracasts
laracasts / usage.php
Last active March 2, 2019 09:42
Little JavaScript helpers for a Laravel app.
{{ Form::open(['data-remote', 'data-remote-success-message' => 'I have now done the thing.']) }}
{{ Form::text('name') }}
{{ Form::submit('Submit', ['data-confirm' => 'Are you sure?']) }}
{{ Form::close() }}
{
"additional_path_items":
[
"/usr/local/php5/bin/"
],
"auto_complete_selector": "source, text",
"bold_folder_labels": true,
"color_scheme": "Packages/Colorsublime-Themes/Facebook.tmTheme",
"font_face": "Fira Code",
"font_options": [],
@laracasts
laracasts / Alert.vue
Created March 15, 2016 02:36
Alert .vue example.
<template>
<div class="Alert Alert--{{ type | capitalize }}">
<slot></slot>
</div>
</template>
<script>
export default {
props: {
type: {
@laracasts
laracasts / ApiTester.php
Last active February 6, 2020 15:57
Incremental APISs: Refactoring Tests and Traits
<?php
use Faker\Factory as Faker;
abstract class ApiTester extends TestCase {
/**
* @var Faker
*/
protected $fake;
@laracasts
laracasts / Accordion.vue
Created May 25, 2018 20:39
vuecasts.com - episode 41 source code.
<template>
<div>
<accordion-item
v-for="(item, index) in items"
:title="item[titleName]"
:body="item[bodyName]"
:key="index"
:is-open="activeItemIndex == index"
@toggled="onToggle"
></accordion-item>
let webpack = require('webpack');
let path = require('path');
module.exports = {
entry: {
app: './resources/assets/js/app.js',
vendor: ['vue', 'axios']
},
output: {