mercredi 17 octobre 2018

Fetch data from database using a 'for loop' with a string value in Laravel

I am using a For loop to show a A to Z button list of students and watch to fetch data from the initials.

@for ($i = 'A'; $i != 'AA'; $i++) 
<h3>Student's Name Starting with ""</h3>
@endfor

I'm using this

public function showByName()
{
  $student = Student::find($name);
  $student_by_name = DB::table('student_list')->where('name', 'LIKE', 
  $name.'%')->limit(30)->get();
  return view('pages.student', ['student_by_name' => $student_by_name]);
}

Instead of using name I want to fetch a list of student starting with the initials of their name or their full name.

Route::get('/student/{name}', 'StudentController@showByName');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire