Reputation: 41
I'm trying to perform the following query in Laravel but have had trouble working out the DB class and Eloquent classes. I would like to do something like the following..
$week = DB::select('SELECT week FROM calendar WHERE year = 2015 and month = 01 and day = 30');
$secondResult = DB::select("SELECT * FROM calendar WHERE year = 2015 and week = $week");
return View::make('calendar')->with('weekdays',$secondResult);
Upvotes: 0
Views: 2586
Reputation: 5444
Try this..
$week = DB::select('SELECT week FROM calendar WHERE year = 2015 and month = 01 and day = 30');
foreach ($week as $weekvalue)
{
echo $weekname=$weekvalue->week;
}
$secondResult = DB::select("SELECT * FROM calendar WHERE year = 2015 and week = $weekname");
return View::make('calendar')->with('weekdays',$secondResult);
Upvotes: 1