Accessor that decrypts model value isn't working Accessor that decrypts model value isn't working laravel laravel

Accessor that decrypts model value isn't working


Just a suggestion to try and override the constructor of the JsonResource and typecast the $resource parameter to your Modelclass.It work's for other things, not sure if it fixes your issue, that needs to be tested

namespace App\Http\Resources;use Illuminate\Http\Resources\Json\JsonResource;use App\Comment;class CommentResource extends JsonResource{  public function __construct(Comment $resource)  {    $this->resource = $resource;    $this->resource->content = $resource->content;  }  ....

Edit:I Played around a bit more with the constructor and the modified version should actually work. I don't have any encrypted data to play with, but logically this should work.