This may be a silly question but I'm stuck..
I basically want to run a simple select query in laravel and show result from a single row in database result.
I'm new to php and laravel so trying to use model in this to get hang on MVC.
Following is what I have done. Route
Route::get('groupprofile/(:any)',array('uses'=>'groups@profile'));
Controller - groups.php
class Groups_Controller extends Base_Controller {
public $restful=true;
public function get_profile($groupName){
$groups=new Groups();
$groupInfo=$groups->getGroupInfo($groupName);
return View::make('groups.profile.groupprofile')->with('groupInfo',$groupInfo);
}
}
Model - groups.php
class Groups{
public function getGroupInfo($name){
return DB::query('select * from Groups where name=?',array($name));
}
}
View - groupprofile.blade.php
@layout('layouts.default')
@section('content')
<h1>This is a profile page for a group.</h1>
@foreach ($groupInfo -> results as $info)
<br />Here I want to display all columns e.g. name, philosophy, founder name etc.
<br />$info->Description
@endforeach
<br />Testing end
@endsection
Can someone please guide me how should I do this? I'm not able to understand how to display data from passed result set in view using blade.
Or is my approach wrong to do this? I'm more comfortable in writing queries so not using Eloquent or fluent query builder.