title: Laravel 5 how to manipulate my variable in an for each in my controller and then pass it to my view
body: <p>I have a database table named 'services'. With the function below I get all the records from that table. This function is located in my ServicesController.php.</p>
  
  <pre><code>public function index() {
    $roadmap = Roadmap::all();
  
  
    return view('services', compact('roadmap'));
  }
  </code></pre>
  
  <p>Now in my view I also do the following:</p>
  
  <pre><code>&lt;?php
          foreach($roadmap as $roadmap_item) {
                $new = array();
                $splitted = explode("|", $roadmap_item-&gt;steps);
  
                foreach($splitted as $split) {
                  $new = explode(":", $split);
                }
              }
  ?&gt;
  </code></pre>
  
  <p>Lets say I get the string 'step1:hello|step2:bye' back from '$roadmap-item->steps'. I split them in substrings with explode etc. This is working by the way. </p>
  
  <p>But is there a way I can manipulate the string in the Controller so my view will be nice and clean without many php code and still remain the variable $roadmap with all the database records.</p>
  
  <p>Kind regards,</p>
  
  <p>Dylan</p>