Livewire: How do I mask the classname that component exposes?
I'm new to Livewire. I want to know if there's a way to mask the classname that component exposes? For example, the wire:snapshot exposes the model information (App\Models\Post) etc.
I remember reading about some mechanism in Livewire that allows masking the sensitive information? AFAIK, there's a way to alter the class name with something vague; like Post can be rendered as 'SomePost' in the wire snapshot.
I'm scouting the entire documentation; but can't find it. I'd really appreciate your help.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Relations\Relation;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Relation::morphMap([
'post' => 'App\Models\Post',
]);
}
}
I want to know if there's a way to hide Model IDs as well?
@thebigk Why are you using Livewire in the first place if you don’t like that it exposes class names and database identifiers?
The golden rule of client-side development is, if you don’t want the user to see it then don’t send it in the first place. It seems Livewire may not be suitable to your use case.
Share the data with the view as an array or discrete properties rather than model objects. If you share the entire model you risk exposing more data than you intended, never mind the class name.