I created 2 functions to same view in same controller but last one only working
This is my function
class ProspectController extends Controller {
public function get_prospects() {
$prospects = DB::select('select * from prospect');
return view('prospect', ['prospects' => $prospects]);
}
public function get_courses() {
$courses = DB::select('select * from course');
return view('prospect', ['courses' => $courses]);
}
}
This is my route
Route::get('prospect', 'ProspectController@get_courses');
Route::get('prospect', 'ProspectController@get_prospects');
This is my view file
@foreach($courses as $course)
<input type="checkbox" id=""
name="course_intrested[]" value="">
<label for="defaultCheck"></label>
@endforeach
But i'm getting this error
Undefined variable:
courses (View:C:\xampp\htdocs\laravel\customer_inquiry_model\resources\
views\prospect.blade.php)
But course function working when I change route like this
Route::get('prospect', 'ProspectController@get_prospects');
Route::get('prospect', 'ProspectController@get_courses');
but first one is not working. This is my problem.....
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire