Question

I'm new with laravel + frameworks and i'm having a few issues.I read the laravel documentation and tried asking for support on their forums - no results/

In my current setup - I followed the laravel documentation & code

I have 1 Model : User

I have 1 table in the db : users

Everything works fine for the login / registration parts etc....

However now i need to create several new tables & maybe some more models :

I searched the web and there are no tutorials or anything else to guide me how to do it.

Any help would be greatly appreciated .

Tried :

In Models -

created : profile.php

class Profile extends Eloquent implements UserInterface, RemindableInterface {

protected $table = 'profile';

}
  • It doesn't seem to work , I'm wondering if i have to link the file or something in the laravel framework etc..

P.s : I used artisan and migrations to create the user table

I am now creating the tables directly in the database but i have no idea how to access them such as :

in the user table , i can use :

Auth::user()->username - to get the username

however in the new table (profile) -

I have absolutely no idea how to access it using laravel code.

Was it helpful?

Solution

Have you read over the documentation http://laravel.com/docs/eloquent?

Create a new file inside of ../app/models/

../app/models/Profile.php

** note the file matches the classname

inside the model:

class Profile extends Eloquent {
    protected $table = 'profile';
}

Then in your controller or route closure access the model via

$profile = Profile::find(1);

or

$profile = App::make('Profile');
$profile->about = 'About the user';
$profile->save();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top