harristars Ответов: 0

Как я могу создать связь между таблицами в laravel и ограничением страницы в зависимости от таблиц


How can i make a relationship between two table in laravel .one table is called defaulters tables that contain all those people that have debts and the other one is called users that have those people that has access to the system.i want to relate these two tables.i have a field called debtors in users table and another called debtors in defaulters table i want those people that have debts not to access some pages when the login and those that have no debts to access those pages .how can i achieve this .please someone help me i stuck.


Что я уже пробовал:

below is my debtors.php middleware and is working fine


 public function handle($request, Closure $next)
{
    if(auth()->user()->debtor == 0){

        return redirect('home')->with('success','You can apply for the
        Service. You have 0  Debt Balance ');
        return $next($request);
    }
    return redirect('home')->with('error','You can not apply for the 
        Service , You have 567  Debt Balance ');
}


this my web.php


//user roles 
Route::get('/home1', 'HomeController@admin')->middleware('debtors');
Route::get('/application_dashboard', 'HomeController@application_dashboard')->middleware('debtors');'

Kornfeld Eliyahu Peter

В основном отношения создаются в БД (MySQL в вашем случае) - вот почему они называются СУБД..

0 Ответов