Ok, so I'm trying to get the syntax for using collections. The laravel documentation and examples just make no sense to me right now. No-one's really talking about collections so:
I have two table entries, one for regions and one for countries. I'd like to be able to do something like group countries by region, so there's no printing of the duplicate regions. In php it makes sense. But in laravel, I don't get how their syntax works.
So how's it done?
This is my controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
class SortController extends Controller
{
public function index(){
$infos = DB::table('list_countries')
->select('Region', 'Country')
->groupBy('Region')
->get();
// $sorts = DB::table('list_countries')->get();
return view('Sort', compact('infos'));
}
}
This is my threadbare blade file:
@extends('layout')
@section('content')
<h1>Hello</h1>
@foreach($infos as $info)
<div class="checkbox">
<label>
{!! Form::checkbox('agree', 'yes', $info->Region) !!}
</label>
</div>
@endforeach
@stop
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire