Giter Club home page Giter Club logo

handler-sanctum's Introduction

Laravel Sanctum API Handler

Latest Version on Packagist Size Code on Packagist issues on Packagist follower on Packagist discussions on Packagist commit on Packagist license on Packagist

Cara menggunakannya :

install Package composer require ibnudirsan/lara-handler-sanctum

Ganti baris kode program ini :

// bootstrap/app.php

<?php

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class,
);

Menjadi seperti ini :

// bootstrap/app.php

<?php

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    Ibnudirsan\LaraHandlerSanctum\Exceptions\HandlerSanctumException::class,
    App\Exceptions\Handler::class,
);

Response Json

    /**
     * Method yang dapat digunakan
     */
    return ResponseJson::cretae($result);
    return ResponseJson::read($result);
    return ResponseJson::show($result);
    return ResponseJson::update();
    return ResponseJson::delete();

Usage Example :

// App/Http/Controllers/usersController.php

<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;
use Ibnudirsan\LaraHandlerSanctum\Halper\ResponseJson;

class usersController extends Controller
{
    public function getUser($id)
    {
        $result = User::where('id',$id)->first();
            return ResponseJson::read($result);
    }
}
// Contoh Return Json

{
    "app": {
        "info": {
            "error": false,
            "Status": "Read Data",
            "httpcode": 200,
            "Message": "Successfully Read Data"
        },
        "result": {
            "data": {
                "name": "ibnudirsan",
                "email": "[email protected]"
            }
        }
    }
}

Publish

Publish package configuration php php artisan vendor:publish --tag=handler-sanctum-config

Secara otomatis akan membuat file handler.php

// config/handler.php

<?php

return [
    
    'hidden' => [
        'email_verified_at',
        'created_at',
        'updated_at',
    ]
];

Note :

  • Di file ini bisa menambahkan atau menguragi filed yang di hidden.

handler-sanctum's People

Contributors

ibnudirsandev avatar ibnudirsan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.