I have my users table with a column named status. In this column I just store a number, based off their status, 1 - admin, 2 - owner, etc. I know that I can display these values with {{ users->status }}, but only shows the stored number. How can I show the actual name instead of the stored number? And I don't use model here.
3 Answers
Comments
You should create a table with user's name role and then join 2 tables. For example: You have 1 table named users with column status. You need to create a table for example user_status_name. id 1 -- name admin, id 2 -- name user
<?php
$users = User::join('user_status_name', 'user_status_name.id', '=', 'users.status')->pluck('name');
?>