Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Fetch all the rows with same column number in laravel

I have a modal button associated with each student on a table. When I press the button I want to be able to fetch all results associated with the admission_num from another table. The code I have is below.

enter image description here

Here is my controller code

public function view_student_result($id)
{

    $user= User::where('admission_num', $id)->get();
    
    $resultdata = juniorResults::where('admission_num', $id)->get();



    return view('backend.student_result_view', compact('resultdata', 'user'));
}

Here is my route

Route::get('view-student-result/{id}', [viewResultController::class, 'view_student_result'])->name('view_student_result');

Here is the button that links to the view result page

  <a href="{{ route('view_student_result', $studentDatas->admission_num) }}"><i class="fas fa-print"></i></a>

When I used get(), I got this error Property [admission_num] does not exist on this collection instance. But when I use first() instead of get() the code was able to fetch just one result. below is the dd(collection)

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

To get all students with a specific Admission_num, you can use this statement:

$resultdata = juniorResults::where('Admission_num', 12345)->get();

Small hint: Instead of writing your url by hand, it is safer to use the name of your route:

<a href="{{ route('view_student_result', $studentDatas['id']) }}"></a>
about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want all rows you dont have to use first(). Instead of first what you returns only the first userobject you have to use all() or get. $user= User::where('admission_num', $id)->get();

small note You screenshot from you database table admission_num is upper case the first letter. And in your eloquent query you have lower case.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda