use Inertia\ResponseFactory;
$this->app->extend(ResponseFactory::class, function (ResponseFactory $original) {
return new CustomResponseFactory($original);
});
namespace App\Extensions\Inertia;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\ForwardsCalls;
use Inertia\Response;
use Inertia\ResponseFactory;
use Laravel\Pennant\Feature;
class CustomResponseFactory
{
use ForwardsCalls;
protected ResponseFactory $original;
public function __construct(ResponseFactory $original)
{
$this->original = $original;
}
public function render(string $component, $props = []): Response
{
if (Feature::active('new-ui')) {
$component = Str::start($component, 'New/');
}
return $this->original->render($component, $props);
}
public function __call($method, $parameters)
{
return $this->forwardCallTo($this->original, $method, $parameters);
}
}
thanks @martinbean, ill try with your method first, but i dont see the fallback method when using new-ui features if component / page in Folder New doesn't exist, just using old component in folder page
As a related comment, I would totally avoid using 'new' for your revised design.
Becomes a mess in the future when you have 'new' folders that are no longer new.
I would start by moving files to be replaced using an 'outgoing' label, fix controllers etc and test it all works, then add the penant switch and create the new view using the original name. When you are happy with the feature you can remove the 'outgoing' files, and not mess with the files you recently created.