Add the transformer to your view using the @transformer directive. The args key can still be used on the @storybook directive, but the purpose here is to inject it from a transformer:
Your base Transformer must call the Blast internal transformer:
public static function blast($transformer, $bladeDefinedVars): array
{
return app(BlastTransformer::class)->transform($transformer, $bladeDefinedVars);
}
Then your transformer must define a transformStorybookData() method that will return the fake data:
<?php
namespace App\Transformers;
class Posts extends Transformer
{
public function transform(): array
{
return [
'title' => $this->title,
];
}
public function transformStorybookData(): array
{
return [
'title' => 'Fake Title to Be Displayed Inside Storybook Only',
];
}
}
To use this on any Twill based application:
Add the transformer to your view using the
@transformer
directive. Theargs
key can still be used on the@storybook
directive, but the purpose here is to inject it from a transformer:Your base Transformer must call the Blast internal transformer:
Then your transformer must define a
transformStorybookData()
method that will return the fake data: