Skip to content

Instantly share code, notes, and snippets.

View aungwinthant's full-sized avatar

awt aungwinthant

  • Yangon
View GitHub Profile
@aungwinthant
aungwinthant / CategoryTest.php
Created September 16, 2019 04:05
Feature Testing Category
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class CategoryTest extends TestCase
{
use RefreshDatabase;
/**
* A basic feature test example.
@aungwinthant
aungwinthant / CategoryController.php
Last active September 16, 2019 05:34
Controller for category
<?php
namespace App\Http\Controllers;
use App\Repositories\CategoryRepositoryInterface;
use Illuminate\Http\Request;
class CategoryController extends Controller
{
protected $category;
@aungwinthant
aungwinthant / CategoryRepositoryTest.php
Last active September 16, 2019 05:36
Unit Testing Save Method
<?php
namespace Tests\Feature;
use App\Models\Category;
use App\Repositories\CategoryRepository;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
@aungwinthant
aungwinthant / AppServiceProvider.php
Created September 16, 2019 03:56
Bind to Container
<?php
public function register()
{
$this->app->bind(CategoryRepositoryInterface::class,CategoryRepository::class);
}
@aungwinthant
aungwinthant / CategoryRepository.php
Created September 16, 2019 03:53
Concrete for Category Repository
<?php
namespace App\Repositories;
use App\Models\Category;
class CategoryRepository extends Repository implements CategoryRepositoryInterface{
public function __construct(Category $category)
{
@aungwinthant
aungwinthant / CategoryRepositoryInterface.php
Created September 16, 2019 03:33
Interface for CategoryRepository
<?php
namespace App\Repositories;
interface CategoryRepositoryInterface{
public function list();
public function save(array $data);
@aungwinthant
aungwinthant / Repository.php
Created September 16, 2019 03:07
Abstract Class For Repository
<?php
namespace App\Repositories;
abstract class Repository{
public function save(array $data){
return $this->model->create($data);
}
@aungwinthant
aungwinthant / FCM.php
Last active July 20, 2023 11:53
Firebase Cloud Messaging with Guzzle HTTP Client (Only For Topics)
<?php
use GuzzleHttp\Client;
class FCM{
protected $endpoint;
protected $topic;
protected $data;
protected $notification;