pboivin
03/01/2022, 5:37 PMamargoCactus
03/01/2022, 5:37 PMscript tag?ifox
03/01/2022, 5:46 PM@php works, right? injecting a service within the block file with @inject should too?ifox
03/01/2022, 5:47 PMifox
03/01/2022, 5:47 PMifox
03/01/2022, 5:48 PMamargoCactus
03/01/2022, 5:48 PM@stack - @push directivesamargoCactus
03/01/2022, 5:48 PMamargoCactus
03/01/2022, 5:48 PMjs/blocks folderamargoCactus
03/01/2022, 5:49 PMifox
03/01/2022, 5:50 PMifox
03/01/2022, 5:51 PMifox
03/01/2022, 5:51 PMamargoCactus
03/01/2022, 5:52 PMamargoCactus
03/01/2022, 5:52 PMifox
03/01/2022, 5:54 PMifox
03/01/2022, 5:54 PMifox
03/01/2022, 5:55 PMamargoCactus
03/01/2022, 5:57 PMpboivin
03/01/2022, 6:01 PM@php from the template. @inject would be a nice improvement for the bread-and-butter cases like pulling stuff from a repository, etc.pboivin
03/01/2022, 6:01 PMkalle
03/01/2022, 6:09 PMResponse? By appending new dynamic method on it which will resolve data for us?kalle
03/01/2022, 6:45 PMView macroable it works 😄
php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
View::macro('injectInBlock', function () {
return 'dynamic data in block';
});
}
}
Block preview file:
php
{!! View::injectInBlock() !!}
Resultkalle
03/01/2022, 6:46 PMcomposer.pboivin
03/01/2022, 7:20 PMAppServiceProvider, could provide access to other useful private methods from the same context.Harings Rob
03/02/2022, 6:56 AMphp
<?php
namespace App\Twill\Block;
use A17\Twill\Services\Blocks\Block;
class TextBlock extends Block
{
public function getFormData(): array
{
return ['test' => self::class];
}
}Harings Rob
03/02/2022, 7:03 AMHarings Rob
03/02/2022, 8:27 AMifox
03/02/2022, 10:13 AMUtuyutuF
03/02/2022, 2:20 PM