1. Go to this page and download the library: Download charlielangridge/playa 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/ */
charlielangridge / playa example snippets
use Illuminate\Support\Facades\Route;
Route::get('/join/{game}', JoinGameController::class)
->middleware(['web', 'playa'])
->name('games.join');
use Illuminate\Http\Request;
public function __invoke(Request $request)
{
$player = $request->player();
// $player is an instance of CharlieLangridge\Playa\Models\Player
}
use CharlieLangridge\Playa\Facades\Playa;
$player = Playa::player();
namespace App\Models;
use CharlieLangridge\Playa\Models\Player as PlayaPlayer;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Player extends PlayaPlayer
{
public function team(): BelongsTo
{
return $this->belongsTo(Team::class);
}
}
'user_id_type' => 'bigint', // bigint, uuid, ulid, or string
use CharlieLangridge\Playa\Events\PlayerCreated;
use Illuminate\Support\Facades\Event;
Event::listen(PlayerCreated::class, function (PlayerCreated $event) {
// $event->player
});
use CharlieLangridge\Playa\Facades\Playa;
Playa::forget();