Search code examples
laravellaravel-3

Use Laravel bundle inside model


I'm using Laravel 3 and want to use Sentry::user as an $include inside one of my models, but it won't let me. So far I have tried "Sentry::user" inside the $include which results in "ap$iw{u[]". I also tried "sentry.user" but that would mean a sentry model (which I don't have) and the user relationship.

So to make this question valuable to others as well: How can you include a model from a bundle inside your own Laravel 3 model?

<?php
public $includes = array('company', '??');

public function company() {
    return $this->belongs_to('Company');
}

public function user() {
    return $this->belongs_to('Sentry::user');
}
?>

Solution

  • I've not used Sentry before but if this model is namespaced under a Sentry namespace then you need to supply the fully qualified namespace to the model. For example:

    return $this->belongs_to('Sentry\User');