We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
If you want to put "sensitive" data in our database then you can use Crypt Facade and handle these using accessors and mutators.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Facades\Crypt;
class CloudProvider extends Model
{
protected function apiToken(): Attribute
{
return Attribute::make(
set: fn ($value) => Crypt::encryptString($value),
get: fn ($value) => Crypt::decryptString($value),
);
}
}
Thanks to @thkafadaris for the idea.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.