Created
January 3, 2014 19:38
-
-
Save evaldosantos/8245026 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Pessoa extends Eloquent { | |
protected $table = "pessoa"; | |
public function telefones() | |
{ | |
return $this->hasMany('Telefone', 'id_pessoa'); | |
} | |
} | |
class Telefone extends Eloquent { | |
protected $table = "telefone"; | |
} | |
// Example | |
return Pessoa::find(18629)->telefones; | |
// Return | |
string(46) "select top 1 * from [tb_pessoa] where [id] = ?" | |
string(67) "select * from [tb_telefone] where [tb_telefone].[id_pessoa] is null" | |
[] |
Tenta
return $this->hasOne('Telefone');
ou
return $this->hasOne('Telefone', 'id_pessoa');
Qual é o tipo de relação da tabelas?
Uma pessoa -> Um ou mais telefones.
É uma relação simples, já usei ela com mysql...sqlite...mas no sqlsrv simplesmente não ta funcionando.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://forums.laravel.io/viewtopic.php?id=12673