I have the following tables:
contacts = > id - name - state - city
states = > id - status - acronym
cities = > id - city - state_id
And the following templates:
State.php
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Estado extends Model{
protected $table = 'estados';
public $timestamps = false;
public function contatos(){
return $this->hasMany('App\Contato');
}
}
Contact.php
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Contato extends Model{
protected $table = 'contatos';
public $timestamps = false;
public function estados(){
return $this->hasMany('App\Estado');
}
}
And to list:
$request = Contato::orderBy($column, $sort)->paginate($paginator);
And how do I make the state name (the same goes for the neighborhood) instead of the state id