Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nasrul Hazim Bin Mohamad nasrulhazim

🎯
Focusing
View GitHub Profile
@nasrulhazim
nasrulhazim / MicrosoftTeam.php
Created May 6, 2020
Microsoft Team Transformer from Webhook
View MicrosoftTeam.php
<?php
namespace App\WebhookClient\Transformers;
use App\Contracts\WebhookPayload as Payload;
class MicrosoftTeam
{
public static function transform(Payload $payload): array
{
View CreateWebhookCallsTable.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateWebhookCallsTable extends Migration
{
public function up()
{
Schema::create('webhook_calls', function (Blueprint $table) {
@nasrulhazim
nasrulhazim / WebhookCall.php
Created May 6, 2020
Extend Webhook Call Model
View WebhookCall.php
<?php
namespace App\Models;
use App\Traits\HasMediaExtended as MediaTrait;
use CleaniqueCoders\LaravelUuid\Contracts\HasUuid as HasUuidContract;
use CleaniqueCoders\LaravelUuid\Traits\HasUuid;
use Illuminate\Http\Request;
use OwenIt\Auditing\Auditable as AuditableTrait;
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
View GitHubSignatureValidator.php
<?php
namespace App\WebhookClient\SignatureValidator;
use Illuminate\Http\Request;
use Illuminate\Validation\UnauthorizedException;
use Spatie\WebhookClient\SignatureValidator\SignatureValidator;
use Spatie\WebhookClient\WebhookConfig;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@nasrulhazim
nasrulhazim / GitHubController.php
Created May 6, 2020
Webhook Handler Controller
View GitHubController.php
<?php
namespace App\Http\Controllers\Webhooks;
use App\Http\Controllers\Controller;
use App\Models\WebhookCall;
use App\WebhookClient\SignatureValidator\GitHubSignatureValidator;
use Illuminate\Http\Request;
use Spatie\WebhookClient\WebhookConfig;
use Spatie\WebhookClient\WebhookProcessor;
View GitHub.php
<?php
namespace App\WebhookClient\Payload;
use App\Contracts\WebhookPayload;
use Illuminate\Support\Str;
class GitHub implements \App\Contracts\WebhookPayload
{
protected $header;
@nasrulhazim
nasrulhazim / laravel.yml
Created Apr 23, 2020
GitHub Action for Laravel
View laravel.yml
name: Unit Test
on:
push:
branches:
- develop
pull_request:
branches:
- develop
release:
@nasrulhazim
nasrulhazim / LearnMiddlewareTest.php
Last active Apr 14, 2020
Learn Middleware Test
View LearnMiddlewareTest.php
<?php
namespace Tests\Feature;
use App\Http\Middleware\LearnUnitTestMiddleware;
use Tests\TestCase;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Mockery;
@nasrulhazim
nasrulhazim / LearnMiddlewareTest.php
Last active Apr 14, 2020
Learn Middleware Test
View LearnMiddlewareTest.php
<?php
namespace Tests\Feature;
use App\Http\Middleware\LearnUnitTestMiddleware;
use Tests\TestCase;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Mockery;
@nasrulhazim
nasrulhazim / LearnUnitTestMiddleware.php
Last active Apr 13, 2020
Learn Unit Test Middleware
View LearnUnitTestMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
class LearnUnitTestMiddleware
{
/**
* Handle an incoming request.
You can’t perform that action at this time.