M
M
Marcuzy2015-05-31 19:23:07
Yii
Marcuzy, 2015-05-31 19:23:07

What is the best way to organize a user model in Yii2?

Hello. There are several types of users with specific fields in the database (some users require a separate table, and the general data is stored in the user table), specific methods and relationships with other tables. I would like to be able to write like this:

$reader = Reader::findOne($id);
$books = $reader->books;
//..
$librarian = Librarian::findOne($id);
$orders = $librarian->orders;
$librarian->clearCart();

+It is convenient to implement access through Yii::$app->user->identity
Question: what is the best way to organize models in this case?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Grechushnikov, 2015-06-02
@maxyc_webber

Has the issue been resolved? The issue is resolved through Relations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question