title: Laravel - Using bundle to retrieve data from db
body: <p>First of all, I'm new to Laravel and MVC environment. For this project, I'm using MySQL as database and Charisma as the bundle. I'm having difficulties when trying to retrieve data from db. I wonder if someone would guide me through all these problems.</p>
  
  <ol>
  <li>If I'm using bundle, where do I put all the models, controllers and the routes? In <code>/application</code> folder, or in the bundle's folder itself?</li>
  <li>When do I use <code>/application</code> folder, and when do I use Charisma folder? (obviously, I'm only using it for the front-end UI)</li>
  <li>I have a record in my database table (named <code>user_links</code>) to test the data retrieval in Charisma View. How do I go about that? </li>
  </ol>
  
  <p>I'm using this <a href="http://www.w3programmers.com/crud-with-pagination-in-laravel/" rel="nofollow">CRUD Tutorial in Laravel</a> as a guide, but it's a little confusing when it comes to using bundle.</p>
  
  <p>Ok, let me try do it my way. I'm going to do a Retrieval here. I hope someone can point out the mistake and guide me for a fix.:</p>
  
  <p><strong>Table</strong> name <code>user_links</code>:</p>
  
  <pre><code>id: int
  user_id: varchar
  link_title: text
  link_url: text
  </code></pre>
  
  <p><strong>Model</strong> <code>/application/models/user_links.php</code> (since Charisma doesn't have <code>/models</code> folder, I'm gonna use the default one):</p>
  
  <pre><code>class User_Link extends Eloquent{
  }
  </code></pre>
  
  <p><strong>Controller</strong> <code>bundles/charisma/controllers/user_link.php</code> (using Charisma controllers folder)</p>
  
  <pre><code>class Charisma_User_Link_Controller extends Base_Controller{
  
    public $restful = true;
  
    public function get_index(){
   $user_links =  User_Link(); 
  return View::make('user_links.index')
  -&gt;with('link_title', 'Link Title')
  -&gt;with('link_url', 'URL');
    }
  }
  </code></pre>
  
  <p><strong>View</strong> <code>/bundles/charisma/views/pages/index.blade.php</code>:</p>
  
  <pre><code>&lt;div &gt;
  @foreach($user_link-&gt;results as $user_links)
      {{ $user_links::link_title }}
      {{ $user_links::link_url }}
  @endforeach
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Routes</strong> <code>/bundles/charisma/routes.php</code>:</p>
  
  <pre><code>Route::controller('charisma::user_link');
  </code></pre>
  
  <p>That's all. Of course there will be some errors, but if you need something more please let me know. Thanks in advance.</p>