Support the ongoing development of Laravel.io →
Requests Eloquent Blade
Last updated 3 months ago.
0

I don't think you will necessarily need to use If(isset)

For the inputs use Input::get('country") and Input::get('city')

Here is a good starting point for the Eloquent ORM

[Guide to using Eloquent ORM] (http://scotch.io/tutorials/php/a-guide-to-using-eloquent-orm-i...)

Last updated 3 months ago.
0

The issue I have is each country and city relates to various fields in my table. I would love an example integrated from my above template.

Last updated 3 months ago.
0

Here is an example.

public function data() {
  if(Input::has("country") || Input::has('city')) {   
    $country = Input::get('country');
    $city = Input::get('city');

    $records = DataListings::where("country", "=", $country)
          ->orWhere("city","=",$city)
          ->get();

    return View::make('data')->with('table', $records)
  }
}
Last updated 3 months ago.
0

Thanks for your help. Here is my current setup now, however I am getting a blank page with no response, what am I doing wrong?

Here is my controllers for data.index:

public function retailers() {
$listings = DB::table('data_listings')
->orderBy('country', 'asc')
->groupBy('country')
->get();

return View::make('data.index')
->with('data_listings', $listings)
}

This is what I am using in your above example (data.show)

public function postRetailers() {
if(Input::has("country") || Input::has('city')) {   
$country = Input::get('country');
$city = Input::get('city');

$records = DataListings::where("country", "=", $country)
->orWhere("city","=",$city)
->get();

return View::make('data.show')
->with('data_listings', $records);
  }
}

Here are the two routes:

// Retailers
Route::get('/retailers', array(
	'as' => 'retailers', 
	'uses' => '[email protected]')
);

Route::get('/retailers/{country}', array(
	'as' => 'find-retailers', 
	'uses' => '[email protected]')
);

Here is data.index view:

@foreach($retailers_listings as $value)
<a  href="{{ URL::to('retailers/' . $value->country) }}">
{{ $value->country }}
</a>
@endforeach

Here is data.show view:

 @foreach($data_listings as $store)
{{ $store->address }}  // etc etc
@endforeach

When I click a link in data.index, it should route to data.show and show give me the fields with in the table that have $country or $city (however only focusing on $country right now). Any suggestions? Is it because we are using input:: and there is no form it's just URL get?

Last updated 3 months ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Panoplr Panoplr panoplr Joined 27 Feb 2014

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.