Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hamzaelmaghari's avatar

Conditional statement

Hi devs, I just need to know how to use conditional statement inside a config file of livewire.

inside config/livewire.php I want to define condition which depends on request.

'layout' => request()->is('/admin') ? 'layouts.admin' : 'layouts.client',

All this inside an array.

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You shouldn't use conditions inside config files. They are meant to be cached to a static value. Conditional logic goes in the rest of your files

2 likes
hamzaelmaghari's avatar

Oh thanky you for answering me.

This means that I have to define layouts in livewire compoennts everytime I have one.

Thanks again <3

Please or to participate in this conversation.