Last active
January 4, 2018 04:45
-
-
Save multiarts/4f807426e32e889c9cccfb749aef399a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
table client: | |
id | |
bairros_id | |
name | |
Table bairros | |
id | |
name | |
*/ | |
class Client extends Model | |
{ | |
public function bairros() | |
{ | |
return $this->belongsTo(Bairros::class); | |
} | |
} | |
// ClientController | |
public function show($id) | |
{ | |
$cat = Client::where('id', $id)->firstOrFail(); | |
return response()->json($cat->bairros); // Aqui o bairros_id quero que ele exiba o nome do bairro | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Wpkenpachi, retornou o mesmo resultado.