SRC General merupakan package yang digunakan oleh aplikasi SRC dan berisi tentang function-function yang bersifat general
-
composer require fjarfs/src-general
- Otomatis terdaftar oleh
Laravel Package Discovery
- Daftarkan service provider di
bootstrap/app.php
$app->register(Fjarfs\SrcGeneral\SrcGeneralProvider::class);
- Otomatis terdaftar oleh
- Helper
-
Access Module
use Fjarfs\SrcGeneral\Helpers\Access as AccessModule; AccessModule::module('http://localhost/api/v1/user/principal/user', $auth);
contoh:
<?php namespace App\Http\Middleware; use Closure; use App\Libraries\Services\Core\Auth; use Fjarfs\SrcGeneral\Helpers\Access as AccessModule; class Access { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $auth = Auth::info(); if ($auth) { if (AccessModule::module($request->path(), $auth) == false) { return response()->json(['message' => 'Tidak ada otorisasi'], 401); } } return $next($request); } }