0

I'm new to defining relationships and frameworks all together, I want to define and create databalse relationships on model without change by hand

for example:

Heres is the relevant information: User Table:

Table: Users
id       - int (auto increment)
user_id  - int - primarykey
username - varchar(20)

Profile Table:

Table: Profile
id    - int (auto increment) - primarykey
name  - varchar(20)

User and profile links for relationship

(Users) user_id     (Profile) id

how to create this relationship with model generator in laravel4 like with YII framework?

this can has one to one or many to many

DolDurma
  • 15,753
  • 51
  • 198
  • 377
  • This cannot be done using generators. Jeffrey Way's generator package is a quasi-standard in the laravel community and there has been a feature request which was declined https://github.com/JeffreyWay/Laravel-4-Generators/issues/124 – thpl Jul 07 '14 at 08:17
  • @ThomasDavidPlat Jeffrey Way's generator can be detect fields lenght such as `varchar(100)` or `int(10)` ? – DolDurma Jul 07 '14 at 09:35
  • There are some answers: http://stackoverflow.com/questions/16470645/autogenerate-model-classes-with-laravel-4-aka-using-an-existing-database-with-l/25008125#25008125 – chickenchilli Jul 30 '14 at 23:05

1 Answers1

0

I'm not sure how it works in Yii, but in Laravel it's pretty easy. You can find all the information you need in the documentation: http://laravel.com/docs/eloquent#querying-relations

If you don't want to create all the relationships by hand but (almost) automatically, check the question I asked 2 days ago: Laravel 4 automatically create relationships in BaseModel - using "with"-array or scopes or what? - I think it will help you with other stuff, like form validation, too

Community
  • 1
  • 1
molerat
  • 946
  • 4
  • 15
  • 43