Skip to content

Instantly share code, notes, and snippets.

View jsdecena's full-sized avatar
👑
Focusing

Jeff Decena jsdecena

👑
Focusing
View GitHub Profile
@jsdecena
jsdecena / order.php
Created October 16, 2017 02:39
Order edit
// Yours
DB::table('orders')->update([
[
'tracking_no' => $request->input('tracking_no'),
'bc_no' => $request->input('bc_no'),
]
]
// Try this:
@jsdecena
jsdecena / OrderUnitTest.php
Created October 16, 2017 02:45
Laracom order edit unit test
/** @test */
public function it_can_update_the_order()
{
$order = factory(Order::class)->create();
$orderRepo = new OrderRepository($order);
$customer = factory(Customer::class)->create();
$courier = factory(Courier::class)->create();
$address = factory(Address::class)->create();
@jsdecena
jsdecena / formarray.ts
Last active December 15, 2017 00:12
Angular FormArray
const ctrl = this.myForm.controls['rows'];
ctrl.controls.forEach((field) => {
const col1 = parseInt(field.get('col1').value, 10);
const col2 = parseInt(field.get('col2').value, 10);
const sum = col1 + col2;
// How to set these values to col3?
// Doesn't work: field.get('col3').setValue(sum);
});
public createForm() {
@jsdecena
jsdecena / CarouselUnitTest.php
Last active March 5, 2019 08:30
Carousel Unit Test File
<?php
namespace Tests\Unit\Carousels;
use Tests\TestCase;
class CarouselUnitTest extends TestCase
{
/** @test */
public function it_can_create_a_carousel()
@jsdecena
jsdecena / CarouselRepository.php
Created March 8, 2018 00:16
Carousel Repository
<?php
namespace App\Shop\Carousels\Repositories;
use App\Shop\Carousels\Carousel;
use App\Shop\Carousels\Exceptions\CreateCarouselErrorException;
use Illuminate\Database\QueryException;
class CarouselRepository
{
@jsdecena
jsdecena / Carousel.php
Created March 8, 2018 00:18
Carousel Model
@jsdecena
jsdecena / CarouselUnitTest.php
Created March 8, 2018 00:19
Carousel Unit Test
<?php
namespace Tests\Unit\Carousels;
use App\Shop\Carousels\Carousel;
use App\Shop\Carousels\Repositories\CarouselRepository;
use Tests\TestCase;
class CarouselUnitTest extends TestCase
{
@jsdecena
jsdecena / CreateCarouselTable.php
Created March 8, 2018 00:20
Create Carousel Table Migration File
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCarouselTable extends Migration
{
/**
* Run the migrations.
@jsdecena
jsdecena / CarouselUnitTest.php
Created March 8, 2018 00:24
Carousel Unit Test
<?php
namespace Tests\Unit\Carousels;
use Tests\TestCase;
class CarouselUnitTest extends TestCase
{
/** @test */
public function it_can_show_the_carousel()
@jsdecena
jsdecena / CarouselModelFactory.php
Created March 8, 2018 00:26
Carousel Model Factory File
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|