Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


What I have tried:

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');'
Posted
Updated 4-May-19 11:26am
v2
Comments
Kornfeld Eliyahu Peter 5-May-19 5:18am    
Basically relationships are created in the DB (MySQL in your case) - that's why they called RDBMS..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900