title: how to save and retrieve base64 encoded data using Laravel model
body: <p>I am doing a web app using Laravel 7 api.
  I receive data with a json request that I must store in the db with a base64 encoding.
  I store the data in this way:</p>
  
  <pre><code>public function create_request(Request $request)
      {
          $req_store = new Req;
          $req_store-&gt;text = base64_encode($request-&gt;input('requestInformations.text'));
          $req_store-&gt;save();
      }
  </code></pre>
  
  <p>Then obviously to retrieve the data of the <code>text</code> column I must use everytime base64_decode().
  My question is that: is there a way to say to Laravel that everytime that I store a new request the column <code>text</code> must be authomatically encoded to base64 and everytime that I retrieve that data from the database the field <code>text</code> must be authomatically base64 decoded? I suppose I must write something in the <code>Req.php</code> model...</p>
  
  <p>Can help?</p>