Instantly share code, notes, and snippets.

View routes.php
// Login middleware
Route::group(['middleware' => 'login'], function () {
Route::post('login', function () {
// 使用 Login 中介層
});
});
View Kernel.php
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
View InsertLogs.php
<?php
namespace App\Http\Middleware\Login;
use Closure;
use Carbon;
use Maras0830\Repository\LogsRepository;
class InsertLogs
{
View MemberLoginEvent.php
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Illuminate\Http\Request;
class MemberLoginEvent extends Event {
use SerializesModels;
public $request;
/**
View MemberLoginEventHandler.php
<?php namespace App\Handlers\Events;
use App\Events\MemberLoginEvent;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldBeQueued;
use Maras\Contracts\LogsRepositoryInterface;
class MemberLoginEventHandler {
protected $logsRepository;
/**
View EventServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
View EventServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
View MemberLoginEventHandler.php
<?php namespace App\Handlers\Events;
use App\Events\MemberLoginEvent;
use Maras\Contracts\LogsRepositoryInterface;
use Auth;
use Carbon\Carbon;
class MemberLoginEventHandler
{
protected $logsRepository;
/**
View AuthController.php
<?php namespace App\Http\Controllers;
use Auth;
use Illuminate\Routing\Controller;
use Maras\Contracts\LogsRepositoryInterface;
class AuthController extends Controller
{
protected $logsRepository;
/**
View broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_KEY'),
'secret' => env('PUSHER_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'host' => 'api-ap1.pusher.com', // if pusher/pusher-php-server < 2.4.1.
'cluster' => 'ap1' // require: pusher/pusher-php-server: ~2.4.1
],
],