Skip to content

Instantly share code, notes, and snippets.

View adamhut's full-sized avatar

Yu Ting Huang adamhut

  • Shapeways
  • Los Angeles
View GitHub Profile
@adamhut
adamhut / SubscribersTest.php
Created May 3, 2018 12:31 — forked from IftekherSunny/SubscribersTest.php
Laravel File Upload API Test
<?php
use Illuminate\Http\UploadedFile;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class SubscribersTest extends TestCase
{
use DatabaseMigrations, WithoutMiddleware;
@adamhut
adamhut / LocaleMiddleware.php
Created April 21, 2018 12:33
Switch language
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;
class LocaleMiddleware
{
@adamhut
adamhut / CanAssertFlash.php
Created April 18, 2018 21:16 — forked from sandervanhooft/CanAssertFlash.php
Assert flash for Laracasts/flash
<?php
namespace Tests;
trait CanAssertFlash
{
protected function assertFlash($level, $message, $important = false, $title = null, $overlay = false)
{
$expectedNotification = [
'title' => $title,
@adamhut
adamhut / README.md
Created April 8, 2018 23:25 — forked from Alymosul/README.md
[Laravel] Seeding data in testing as part of the application build.

SeedDatabase trait along with SeedDatabaseState class gives your Laravel project the ability to seed the testing database once before running the full suite tests, which improves the speed of the tests than seeding the testing database before each test.

Also, it has the option to run custom seeders instead of the seeders that are called in the run() method of the DatabaseSeeder class you can achieve that as follows

...in the Testcase.php

public function setUp()

{

@adamhut
adamhut / gist:b350ac6c6358cbae1b1d8920e7bf533a
Created March 14, 2018 13:52
Composer Syntax to load different Version of package
composer create-project --prefer-dist laravel/laravel <project-name> "5.5.*"
@adamhut
adamhut / Schedulable.php
Created March 9, 2018 14:39 — forked from davidpiesse/Schedulable.php
Laravel Custom Class/Model Scheduling
<?php
//Don't forget to change the namespace!
namespace App\Traits;
use Cron\CronExpression;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ManagesFrequencies;
trait Schedulable{
<?php
namespace App;
use Event;
use Closure;
class CommandEventsListener
{
protected $startCallbacks = [];
@adamhut
adamhut / forge.sh
Created January 8, 2018 16:57
Laravel Forge Setup Script
#
# REQUIRES:
# - server (the forge server instance)
# - event (the forge event instance)
# - sudo_password (random password for sudo)
# - db_password (random password for database user)
# - callback (the callback URL)
#
@adamhut
adamhut / daterangeWrapperVue.html
Created November 29, 2017 21:43
Daterange Vue JS Wrapper Component BY Paul Redmond
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue Datetime Picker Component</title>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/bootstrap/3/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css"/>
<style type="text/css">
body {
margin: 5em;
@adamhut
adamhut / macro.php
Created November 7, 2017 16:18 — forked from juukie/macro.php
Laravel social media url macro
<?php
URL::macro('social', function ($name, $replacement = '#') {
return array_get([
'facebook' => 'https://www.facebook.com/mypage/',
'instagram' => 'https://www.instagram.com/mypage/',
'pinterest' => 'https://nl.pinterest.com/mypage/',
], $name), $replacement);
});