You can simply create a model like this
class Main extends Eloquent {
protected $table = 'mainTable';
}
Then from your controller you can use following code to get all records from mainTable table:
$title = "Main Page";
$data = Main::get(array('title'))->toArray(); // Or Main::all(['title']);
return View::make('mainpage')->with('data', $data)->with('title', $title);
Update: You can use something like this if you want
class Main extends Eloquent {
protected $table = 'mainTable';
public function scopeGatAllByFieldName($q, $field = null)
{
if(is_null($field)) return $q;
return $q->select([$field]);
}
}
From your controller you may call it like:
$title = "Main Page";
$data = Main::gatAllByFieldName('title')->get()->toArray();
return View::make('mainpage')->with('data', $data)->with('title', $title);