DaGenius
258
17
Laravel

Can't login to Admin section on Server

Posted 2 months ago by DaGenius

Admin section works fine on my local machine but when I upload to my hosting, trying to access the admin backend using username and password combination returns 500 error. When I checked the log files, here is what I saw:

ERROR: Trying to get property of non-object (View: /../resources/views/admin/students.blade.php) {"userId":1,"exception":"[object] (ErrorException(code: 0): Trying to get property of non-object (View: /../resources/views/admin/students.blade.php) at /../app/Student.php:46, ErrorException(code: 0): Trying to get property of non-object at /../app/Student.php:46)

Here's what my students.blade.php looks like:

          @if(!empty($students))
            @foreach($students as $key => $value)
           
            <tr>
              <td>{{$key+1}}</td>
              <td>{{$value->surname . " " .$value->firstname . " " . $value->othername}}</td>
              <td>{{$value->getRegisteredBy($value->registeredBy_id)}}</td>
              <td>{{$value->getMother($value->id)}}</td>
              <td>{{$value->getFather($value->id)}}</td>
              <td>{{date_format(date_create(substr($value->created_at,0,10)),"d-m-Y")}}</td>
              <td><a href="{{url('/admin/viewStudent/'.$value->id)}}" class="btn btn-info btn-sm">View details</a></td>
            </tr> -->
            @endforeach
          @endif

          </tbody>

And the Student.php line 46:

public function getMother($id) {
        $parent = Mother::where('student_id', $id)->first();
        return $parent->name; // line 46
 }

I am not sure why everything works fine on my local machine but refuses to work on the hosting server. I will appreciate your help.

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