0

There's a college alumni portal, where the admin logins and he has to get in details of his colleges only based on the college ID (college ID will be specified by admin during registration and by students when they add their regno's). How to pass the college ID during logging in so that only the details of the specific college based on admin college ID will be displayed?

class AdminAuthController extends Controller
{
    use AuthenticatesUsers;

   
    protected $redirectTo = '/admin/login';

    

    public function registration()
    {
        return view('admin.auth.register');
    }
    public function create(array $data)
    {
        return Admin::create([
            'collegeID' => $data['collegeID'],
            'email' => $data['email'],
            'password' => Hash::make($data['password'])
        ]);
    }

    public function signupsave(Request $request)
    {
        $request->validate([
            'collegeID' => 'required|exists:college_names|unique:admins',
            'email' =>   'required|email|unique:admins',
            'password' => 'required'
        ], [


            // 'password.min' => 'The password must be at least 6 characters.',
        ]);
        $data = $request->all();
        $check = $this->create($data);

        return redirect("admin/login")->with('success', 'You have registered successfully.');
    }

    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }

    public function getLogin()
    {
        return view('admin.auth.login');
    }

    
    public function postLogin(Request $request)
    {
        $this->validate($request, [
            'email' => 'required|email',
            'password' => 'required',
        ]);

        if (auth()->guard('admin')->attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) {
            $user = auth()->guard('admin')->user();


            return view('admin.auth.dash1');
        } else {
            return back()->with('error', 'your username and password are wrong.');
        }
    }

    public function dashboard(Request $request)
    {
        if (Auth::check()) {
           
            return view('admin.auth.dash1');
        } else
            return Redirect::to("admin/login")->withSuccess('Oopps! You do not have access');
    }

   
    public function logout(Request $request)
    {
        $request->session()->flush();
        Auth::logout();
        return Redirect('admin/login');
    }


     }
    public function index1(Request $request)
    {
         
            $collegeID=Admin::get('collegeID')->first();
           //print($collegeID);
           
        $data1['colleges'] = College::select('id', 'regno', 'collegeID')->where('collegeID',$collegeID)->get();
       
        return view('admin.auth.index', $data1);
    }


    public function asd($id)
    {
        $id = auth()->user()->id;
        print_r($id);
    }
}


view:

 <div class="row">
        <div class="col-12 table-responsive">
            <table class="table table-bordered user_datatable" id="user_datatable">
            <thead>
           <tr>
                       
           <center>  <th><strong>ID</strong></th> </center>
                        <th><strong>Register Number</strong></th>
                        <!-- <th>College Name</th> -->
                        <th>College ID</th>
                    </tr> 
                </thead>
              

                <tbody>

                @foreach ($colleges as $college)
        <tr align="center">
        <td>{{ $college->id }} </td>
          <td>{{ $college->regno }} </td>
          <td>{{ $college->collegeID }} </td>
        </tr>

        @endforeach

                </tbody>
            </table>

0 Answers0