The
csrf_token
function retrieves the value of the current CSRF token:<?php $token = csrf_token();
<?php $versionHash = $manifest['/livewire.js'];
$url = "{$url}?id={$versionHash}";
$token = app()->has('session.store') ? csrf_token() : '';
$assetWarning = null;
<?php $progressBar = config('livewire.navigate.show_progress_bar', true) ? '' : 'data-no-progress-bar';
$attributes = json_encode([
'csrf' => app()->has('session.store') ? csrf_token() : '',
'uri' => app('livewire')->getUpdateUri(),
'progressBar' => $progressBar,
'nonce' => isset($options['nonce']) ? $options['nonce'] : '',
<?php function csrf_field()
{
return new HtmlString('<input type="hidden" name="_token" value="'.csrf_token().'" autocomplete="off">');
}
}
<?php {
public function __invoke()
{
return csrf_token();
}
}
<?php Statamic::provideToScript([
'version' => Statamic::version(),
'laravelVersion' => app()->version(),
'csrfToken' => csrf_token(),
'cpUrl' => cp_route('index'),
'cpRoot' => str_start(config('statamic.cp.route'), '/'),
'urlPath' => Str::after(request()->getRequestUri(), config('statamic.cp.route').'/'),
<?php 'environment' => app()->environment(),
'xml_header' => '<?xml version="1.0" encoding="utf-8" ?>', // @TODO remove and document new best practice
'csrf_token' => csrf_token(),
'csrf_field' => csrf_field(),
'config' => config()->all(),
'response_code' => 200,
<?php tap($this->cascade()->hydrate()->toArray(), function ($cascade) {
$this->assertEquals(app()->environment(), $cascade['environment']);
$this->assertEquals('<?xml version="1.0" encoding="utf-8" ?>', $cascade['xml_header']);
$this->assertEquals(csrf_token(), $cascade['csrf_token']);
$this->assertEquals(csrf_field(), $cascade['csrf_field']);
$this->assertEquals(config()->all(), $cascade['config']);