PHP code example of ibnudirsan / handler-sanctum

1. Go to this page and download the library: Download ibnudirsan/handler-sanctum library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ibnudirsan / handler-sanctum example snippets


// bootstrap/app.php



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


// bootstrap/app.php



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



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


// App/Http/Controllers/usersController.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);
    }
}

 php artisan vendor:publish --tag=handler-sanctum-config 

// config/handler.php



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

 handler.php