Skip to content

Instantly share code, notes, and snippets.

View sirawitpra's full-sized avatar

Sirawit Praditkul sirawitpra

View GitHub Profile
<?php
namespace Tests\Feature;
use Tests\DuskTestCase;
use Laravel\Dusk\Concerns\ProvidesBrowser;
class LoginTest extends DuskTestCase
{
use ProvidesBrowser; // 1. Import this trait to your test
<?php
class CustomerAddress extends Model {
protected function setKeysForSaveQuery(Builder $query)
{
$query
->where('Customer_No', '=', $this->getAttribute('Customer_No'))
->where('Address_Name', '=', $this->getAttribute('Address_Name'));
<?php
class Resource extends Model {
protected function setKeysForSaveQuery(Builder $query)
{
$query
->where('pk_1', '=', $this->getAttribute('pk_1'))
->where('pk_2', '=', $this->getAttribute('pk_2'));
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Register;
use App\Repositories\UserRepository;
use App\Transformers\UserTransformer;
class UsersController
{
@sirawitpra
sirawitpra / UsersController.php
Last active December 12, 2017 15:50
Messy UsersController
<?php
namespace App\Http\Controllers;
class UsersController
{
public function register()
{
// validate inputs
$validator = \Validator::make([
<?php
use Foo\Cart;
use Foo\CartItem;
use Foo\FreshMilk;
use Foo\ThisConditionReturnItemInterface;
class FreeFreshMilkWhenByAmericanoEspresso implements ThisConditionReturnItemInterface
{
$needToBuyBothToGetFreeFreshMilk = false;
<?php
class Search
{
private $updateStart;
private $updateEnd;
private $entryCompleted;
<?php
// cool previous code
public function handler()
{
$bar = Partyline::getOutput();
Search::onUpdateStart(function($totalEntries) use (&$bar) {
Partyline::line('Updating the index...');
<?php
class Search
{
public function update()
{
Partyline::line('Updating the index...');
$entries = Entry::all();
<?php
// previous code
public function handle()
{
$this->line('Updating the index...');
Search::update(); // ¯\_(ツ)_/¯