Support the ongoing development of Laravel.io →
Eloquent Architecture
Last updated 2 years ago.
0

Hey DrPrez,

What I mean is, that the categories shown will be the same, but the content of each category will be different for each country.

Makes sense?

Last updated 2 years ago.
0

Thanks man, ill give it a go! Otherwise ill get back here :)

Last updated 2 years ago.
0

I have now set up my migrations as well as my relationships in the various models. The structure is as follows:

Cities
    Categories
        Products

Querying works as expected, however my problem is that I cannot wrap my head around showing all the categories and populate them with data according to the specific city.

Down below is what i've tried so far, which is essentially just a duplicate of some other code which I use to display my categories with products.

... // CitiesController

	public function getCity($city_id) {
	return View::make('cities.category')
		->with('categories', Category::where('city_id', '=', $city_id)->paginate(6))
		->with('cities', City::find($city_id));
}

 // cities.category view
@extends('layouts.default')
@section('content')
	<h1>Cities</h1>
	@foreach($citynav as $city)
		<li>{{ HTML::link('/cities/category/'.$city->id, $city->name) }}</li>
	@endforeach
@stop

I'm not even sure this would yield me the desired result (if it worked), since this would probably return all the categories with all of the products, regardless which city is chosen?

Can anyone help me here? :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Reached reached Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.