I'm not using the auto increment for the id instead i'm using the 32 char unique id. So when i create a relationship and query, im getting a null because my FK expecting int my models
class User extend Eloquent {
public $incrementing = false;
}
class Reservation extend Eloquent {
public $incrementing = false;
}
so when i query this
$reservations = Reservation::with('user')->where('user_id', '=', '22beb4892ba944c8b1895855e1d4d1ad')->get();
i could not retrieve the users information but the reservations info is working fine
when i try to listen for query. eg:
Event::listen('illuminate.query', function($query, $bindings, $time, $name){
var_dump($query);
var_dump($bindings);
});
i get this
string(46) "select * from `reservation` where `user_id` = ?"
array(1) {
[0]=>
string(36) "22beb4892ba944c8b1895855e1d4d1ad"
}
string(53) "select * from `user` where `user`.`id` in (?)"
array(1) {
[0]=>
int(0)
}
the problem is in the second query i could not retrieve the users info because the user.id expecting int.
First, with innoDB you could make those foreing keys without problem
Mabe you have your tables wrong, try this
For Reservations
for users
then you need to create the relationship in reservations
and now when you search
it must work! i've tested this code.