no data is showing from db

Posted 1 month ago by alphadev

firstly I was getting all data into a dropdown then i tried to get all the matching data (tried to match the logged-in user email or name with filename) into dropdown, (which includes two diff. tables), like one table is "users" and other is "files" i.e: in files table column(filename) diff. filename is John Doe, Erik Doe, Wak Edge ,,, and in users table a name is Doe and email is [email protected] , If a user login from [email protected] then he gets all data having Doe at its end. but it gives no outputt:


    public function index(Request $request)

    $files = File::all();
    if (Auth::user()->admin == 0) {
        $selectedFile = File::find($request->Student);
        $file = Auth::user()->files;
        return view('home', compact('file', 'files', 'selectedFile'));
    } else {
        $users['users'] = \App\User::all();
        return view('layouts.master', $files);

    $users = DB::table('users')->select('name', 'email as user_email')->get();
    ->join('files', function ($join) {
        $join->on('', '=', 'files.user_id')
             ->where('files.user_id' == 'filename');

blade file:

     <div class="form-group">
              <form oninput="this.submit()">
                <label class="text-left">Select Student</label>
                @if (Auth::user()->email == filename)
                    <select name="Student" id="Student" style="padding: 5px; border-radius: 3px;">
                      <option value="">Select Student</option>
                      @foreach ($files as $file)
                      <option value="{{ $file->id }}">{{ $file->filename }}</option>

these are both tables:

      Schema::create('users', function (Blueprint $table) {

   Schema::create('files', function (Blueprint $table) {

m getting all records using this code:

Please sign in or create an account to participate in this conversation.