I need help in Laravel.
I need to list all VIEWS from db.
I have written this query in my Controller:
$reports = DB::select("Select TABLE SCHEMA", TRIM('r_all_' FROM TABLE_NAME) as viewname FROM information_schema.tables WHERE TABLE_TYPE LIKE 'VIEW' AND table_schema LIKE 'mprm_shared' AND TABLE_NAME LIKE 'r_all_%'");
With this code I am getting all the views, but in my Model I have only this code:
protected $table = ‘r_all_users’;
With this code I can see the table only from this view: r_all_users.
What I need to change to display tables from All VIEWS, not only from r_all_users?
I need help in my code and I think it is good to ask this
2
Answers
you can:
Lists all the tables in all databases
Lists all the tables in a particular database
You can use laravel Schema method
getAllTables()
It would return an array that contains all table names.