Pixelairport was awarded Best Answer+1000 XP
2mos ago
I just found out I can replace core.blade.php with core.md ... that also works.
Pixelairport wrote a reply+100 XP
2mos ago
I just found out I can replace core.blade.php with core.md ... that also works.
Pixelairport started a new conversation+100 XP
2mos ago
I want to structure my coding standards in md files in a composer package. At the moment i create a core.blade.php in my package for boost and this works. Now I want to create a directory /package/resource/markdown/ ... to load files from this directory instead put all in the core.blade.php. Is that possible? Because I dont understand how? I already tried it like in spatie package: https://github.com/spatie/boost-spatie-guidelines/blob/main/resources/boost/guidelines/core.blade.php and also tried it like in filament/blueprint, where its just say:
**Start here**: Read
`/vendor/.../overview.md`
Pixelairport wrote a reply+100 XP
5mos ago
Thx @glukinho . I already tried it. Sorry, my question was not so clear. I saw in docs there is rules, but it does not work. But now its clear. It works, but only backend. I hoped it also works for the frontend fields. I will do it the filament way and use my DTOs for the backend and for filament I will go on set everything manual for each field.
Pixelairport started a new conversation+100 XP
5mos ago
Does anybody know, if it is possible to do something like:
TextInput::make('title')->rules(['required','max:32'])
instead of
TextInput::make('title')->maxLength(32)->required(),
because I want to use Spatie DTO also for Filament forms or is that a bad idea?
Pixelairport was awarded Best Answer+1000 XP
5mos ago
If also the AI does not answer, you know you ask a boring questions :P ....
I think I have the solution. The code above seems ok. If I inject different user models in test and live code I remove use Workbench\Models\User or use App\Models\User and in the function I do public function viewAny($user) without to define User before $user. This ist the function. For all who also use Spatie Permissions like me, you also have to set the guard as second parameter in the hasPersmissionTo method. It took me a bit time to find out. But I think this is the best workaround for Spatie Permissions with Policies in Orchestra Workbench.
public function viewAny($user): bool
{
if($user->hasPermissionTo(PostPermission::VIEW_ANY->value, 'web')) {
return true;
}
return false;
}
Pixelairport wrote a reply+100 XP
5mos ago
If also the AI does not answer, you know you ask a boring questions :P ....
I think I have the solution. The code above seems ok. If I inject different user models in test and live code I remove use Workbench\Models\User or use App\Models\User and in the function I do public function viewAny($user) without to define User before $user. This ist the function. For all who also use Spatie Permissions like me, you also have to set the guard as second parameter in the hasPersmissionTo method. It took me a bit time to find out. But I think this is the best workaround for Spatie Permissions with Policies in Orchestra Workbench.
public function viewAny($user): bool
{
if($user->hasPermissionTo(PostPermission::VIEW_ANY->value, 'web')) {
return true;
}
return false;
}
Pixelairport started a new conversation+100 XP
5mos ago
I use spatie permissions in my package and want to test with orchestra. That means I need Workbench\Models\User::class instead of User\Models\User::class as user model. I set this in phpunit.xml:
<env name="AUTH_MODEL" value="Workbench\Models\User::class"/>
Now I want to test the policy. But the user model implements spatie permissions trait and then the user has the function $user->hasPermissionTo('viewAny').
The question is, how to make the policy now. In the past I had:
use App\Models\User;
public function viewAny(User $user): bool
{
if($user->hasPermissionTo(PostPermission::VIEW_ANY->value)) {
return true;
}
return false;
}
that is not possible because now I use workbench for test. The user model should come from my config. So I need to delete use App\Models\User;. AI and Google says I should use use Illuminate\Contracts\Auth\Authenticatable; instead, but then my function to check permission is not available. But how should I inject the correct user model at data binding? Or is it a normal way to delete the type in this situation? I mean ...
// do
public function viewAny($user): bool
// instead of
public function viewAny(Authenticatable $user): bool
Does anybody know, what is the best or the standard way here?