In Laravel 4 I want to use a model that represents an Event
coming from my database. Thus, in app/models
I have my Event
model that extends Eloquent.
However, Laravel 4 already has an Event
class which is used to manage events within the application lifecycle.
What I want to know is, how can I properly namespace my Event
model and access it in a way that will not clash with the existing Event
class.
You just need to apply a namespace to it as you normally would. So, for example.
<?php namespace Models;
use Eloquent;
class Event extends Eloquent {
}
You should then correctly setup your composer.json
so that it loads your models. You could use classmap
or psr-0
for this, depending on whether or not you're following PSR-0 with your directory structure.
I'm pretty sure the models
directory is already mapped.
Edit
As mentioned in the comments you must run composer dump-autoload
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With