Answers for "laravel sanctum"

PHP
0

laravel sanctum

//install
composer require laravel/sanctum
  
// vendor
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
Posted by: Guest on August-15-2021
0

laravel sanctum

composer create-project --prefer-dist laravel/laravel appname

composer require laravel/sanctum

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"

composer require laravel/jetstream  
  
php artisan jetstream:install inertia                            

php artisan migrate  
  
npm install  

php artisan vendor:publish --tag=jetstream-views 

php artisan serve

npm run hot
Posted by: Guest on July-30-2021
1

laravel sanctum

return $user->createToken('token-name', ['server:update'])->plainTextToken;
Posted by: Guest on July-24-2021
1

laravel sanctum

use Illuminate\Http\Request;

Route::post('/tokens/create', function (Request $request) {
    $token = $request->user()->createToken($request->token_name);

    return ['token' => $token->plainTextToken];
});
Posted by: Guest on July-22-2021
1

laravel sanctum

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;

Route::post('/sanctum/token', function (Request $request) {
    $request->validate([
        'email' => 'required|email',
        'password' => 'required',
        'device_name' => 'required',
    ]);

    $user = User::where('email', $request->email)->first();

    if (! $user || ! Hash::check($request->password, $user->password)) {
        throw ValidationException::withMessages([
            'email' => ['The provided credentials are incorrect.'],
        ]);
    }

    return $user->createToken($request->device_name)->plainTextToken;
});
Posted by: Guest on February-16-2021
0

laravel sanctum

composer require laravel/sanctum
Posted by: Guest on October-30-2020
0

laravel sanctum

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
Posted by: Guest on October-19-2020
0

laravel sanctum

window.Echo = new Echo({
    broadcaster: "pusher",
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: true,
    key: process.env.MIX_PUSHER_APP_KEY,
    authorizer: (channel, options) => {
        return {
            authorize: (socketId, callback) => {
                axios.post('/api/broadcasting/auth', {
                    socket_id: socketId,
                    channel_name: channel.name
                })
                .then(response => {
                    callback(false, response.data);
                })
                .catch(error => {
                    callback(true, error);
                });
            }
        };
    },
})
Posted by: Guest on July-24-2021
0

laravel sanctum

axios.defaults.withCredentials = true;
Posted by: Guest on July-24-2021
0

laravel sanctum

use Illuminate\Http\Request;

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
Posted by: Guest on July-24-2021

Code answers related to "laravel sanctum"

Browse Popular Code Answers by Language