How to link two column of one table using a single method Eloquent?


tell me how to link two column of one table with one column of another table ?
problem: in admin panel we need to display the user name who created the entry and edit the entry as it correctly to implement ? or just create two separate connection with the users table ?
in the same context to specify the second argument in the array of multiple fields not working
public function user()
 return $this->'s belongsto('App\User', ['created_by', 'modified_by']);
June 5th 19 at 22:03
1 answer
June 5th 19 at 22:05

Why not make 2 methods for each field? It is easier to understand.

public function userCreated()
 return $this->'s belongsto('App\User', 'created_by');

public function userModified()
 return $this->'s belongsto('App\User', 'modified_by');
Thanks for the reply! probably the only way - nikita.Stracke commented on June 5th 19 at 22:08

Find more questions by tags Laravel