-1

Please help check the code to see where there is error as I am not a coder but just using the application from another developer

            <div class="bs-example widget-shadow table-responsive" data-example-id="hoverable-table"> 
                <table class="table table-hover"> 
                    <thead> 
                        <tr> 
                            <th>ID</th> 
                            <th>Client name</th>
                            <th>Amount</th>
                            <th>Payment mode</th>
                            <th>Receiver's email</th>
                            <th>Status</th> 
                            <th>Date created</th>
                            <th>Option</th>
                        </tr> 
                    </thead> 
                    <tbody> 
                        @foreach($withdrawals as $deposit)
                        <tr> 
                            <th scope="row">{{$deposit->id}}</th>
                            <td>{{$deposit->duser->name}}</td>
                             <td>{{$deposit->amount}}</td> 
                             <td>{{$deposit->payment_mode}}</td> 
                             <td>{{$deposit->duser->email}}</td> 
                             <td>{{$deposit->status}}</td> 
                             <td>{{$deposit->created_at}}</td> 
                             <td> <a class="btn btn-default" href="{{ url('dashboard/pwithdrawal') }}/{{$deposit->id}}">Process</a></td> 
                        </tr> 
                        @endforeach
ajovi4ever
  • 13
  • 4

1 Answers1

1

The problem is in {{$deposit->duser->name}} and {$deposit->duser->email}}. Every withdrawal must have a valid user ID. This user ID will be matched against user table and the name and email of that user will be showed in blade.

What is happening is this, one or more $deposit has invalid user ID. So, the blade is trying to search in the table to get the name and email. But it is not finding it. So essentially it is trying to get the name value of a null object and crashing the app.

You can try to check if the duser have a null value by using following code,

@foreach($withdrawals as $deposit)

    @if(!is_null($deposit->duser))

     <tr> 
      <th scope="row">{{$deposit->id}}</th>
      <td>{{$deposit->duser->name}}</td>
      <td>{{$deposit->amount}}</td> 
      <td>{{$deposit->payment_mode}}</td> 
      <td>{{$deposit->duser->email}}</td> 
      <td>{{$deposit->status}}</td> 
      <td>{{$deposit->created_at}}</td> 
      <td> <a class="btn btn-default" href="{{ url('dashboard/pwithdrawal') }}/{{$deposit->id}}">Process</a></td> 
                        </tr> 

    @endif
@endforeach
Nabil Farhan
  • 1,444
  • 3
  • 25
  • 41