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

sllkevin's avatar

sllkevin wrote a reply+100 XP

4mos ago

Is it normal for 404.blade to respond as 301?

That's my thinking, but shouldn't bots and crawlers or curl pings receive a proper 404 response? I just checked the standard Laravel 404 (dark 404 | NOT FOUND page) and the response is 404 in dev tools. But my custom 404.blade is 301.

sllkevin's avatar

sllkevin started a new conversation+100 XP

4mos ago

Is it normal for 404.blade to respond as 301?

When using the browser network tools, I can see that any missing route originally reveals 404 before the official response as a 301 redirect to the 404.blade template.

However, I'm checking my Nginx access logs and all the bots pinging random wordpress routes all show the response as 301. Is this normal behavior?

sllkevin's avatar

sllkevin wrote a reply+100 XP

5mos ago

Livewire - manipulate data before validation

I discovered this topic after having a similar issue. However, updatingProperty($value) does not seem to work with my scenario where I'm using #[Validate] attribute on the property for a domain URL in a simple Volt component.

In my case, I wrote a function to ensure "https://" is prefixed to a string before validating, otherwise the validation will fail immediate, on blur. I wanted to format that string before validation.

My solution is to call the filter function in the rules() method just before returning the rules array. See summary of my solution below:

#[Validate]
public ?string $domain;

protected function rules()
{
	$this->domain = isset($this->domain) 
		? Application::formatDomainString($this->domain) : null;

	return [
		'domain' => 
'nullable:string|url:http,https|unique:applications,domain,'.$this->application->id,
	];
}
<flux:input wire:model.blur="domain" />
sllkevin's avatar

sllkevin wrote a reply+100 XP

5mos ago

How to return Flux component from a class method?

The code above is just an example of the syntax I'm looking for, similar to how the Flux docs explain Flux::modal->close().

I understand that's what blade is for, but Flux is already a view/component and putting it in another view/component seems redundant. If i wanted to render a Flux badge it'd be nice to just return the badge instead of a whole separate view.

The first return as a static method probably wouldn't work well if to require the additional wrappers. However, i'm not sure how to reference the views path to flux components. By convention, return view('flux.menu.item') should work but it does not, even as a namespace flux::menu.item.

My solution so far is a Volt component with blade @if conditionals which i don't like. However my small project it's not a dealbreaker.

sllkevin's avatar

sllkevin started a new conversation+100 XP

5mos ago

How to return Flux component from a class method?

Is there a way to have a class method return a Flux component? My work around was to create my own blade component to hold the Flux tags then return view('my-flux-component'). But can I just call Flux directly without concatenating a string in the method?

For example, I have a list of Posts I want to add an action menu: View, Delete, etc. I want to have an action class that handle() but also render the menu item.

// Example
class Post
{
	public $actions = [
		Actions\ViewPost::class,
		Actions\DeletePost::class
	];
}
//Example
class Actions\ViewPost
{
	public static function menuItem()
	{
		// What I'm trying to achieve
		return Flux::menuItem( $attributes... );
		// or...
		return view('flux::menu.item', [...]);
	}
}