lyubamt
1 month ago
197
5
Laravel

error in pagenation

Posted 1 month ago by lyubamt

I have this controller

//
 $assessments=Assessment::paginate(5);
           
         //fetch enrolled data
        //$enrollments= Enrollment::all();

        //$enrollments = DB::table('enrollments')->get();
        $assessment_list=array();
        foreach($assessments as $assessment) {
            ///dd($assessment->module_id);
            //dd(Course::getCourseName($assessment->module_id) );
            $names = DB::table('contacts')
                            ->select('id','first_name', 'last_name')
                            ->where('id', '=', $assessment->contact_id)
                            ->get();

            foreach($names as $name) {
                $assessment_list[] = array(
                    'assessment_id'=>$assessment->assessment_id,
                    'first_name' => $name->first_name,
                    'last_name' => $name->last_name,
                    'module_name'=>Course::getCourseName($assessment->module_id),
                    'module_code'=>Course::getCourseCode($assessment->module_id),
                    'academic_year'=>$assessment->academic_year,
                    'semester'=>$assessment->semester,
                    'coursework'=>$assessment->coursework,
                    'final' => $assessment->final
                );
            }
        }

        return view('assessments.index',compact('assessment_list'));

my view

                <thead>
                <tr>
                    <td>Assessment ID</td>
                    <td>Contact Name</td>
                    <td>Module Name</td>
                    <td>Module Code</td>
                    <td>Academic Year</td>
                    <td>Semester</td>
                    <td>Coursework</td>
                     <td>Final</td>
                    <td colspan = 2>Actions</td>
                </tr>
                </thead>
                <tbody>
                @foreach($assessment_list as $value)
                    <tr>
                        <td>{{$value['assessment_id']}}</td>
                        <td>{{$value['first_name']}} {{$value['last_name']}}</td>
                        <td>{{$value['module_name']}}</td>
                        <td>{{$value['module_code']}}</td>
                        <td>{{$value['academic_year']}}</td>
                        <td>{{$value['semester']}}</td>
                        <td>{{$value['coursework']}}</td>
                        <td>{{$value['final']}}</td>
                        <td>
                            <form action="{{ route('assessments.destroy',  $value['assessment_id'])}}" method="post">
                                @csrf
                                @method('DELETE')
                                <button class="btn btn-danger" type="submit">Delete</button>
                            </form>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            <div>
            </div>
  {{ $assessment_list->links() }}
```
i got this error
Facade\Ignition\Exceptions\ViewException
Call to a member function links() on array (View: C:\xampp\htdocs\crudApp\resources\views\assessments\index.blade.php) 
any help please

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