dimanche 2 juillet 2023

undefined variable client_details in laravel

I am new in laravel, I need assistance in displaying data from database on laravel blade view but I am getting the error, "undefined variable client_details" even though it is defined in my controller.

below is what I did in my controller:

namespace paylesotho\Http\Controllers;

use Illuminate\Http\Request;
use paylesotho\Utility_data;
use DB;


class UtilityManagementController extends Controller
{
    //display clients data on a table

    public function index(){
        $clients = Utility_data::latest()->paginate(6);
        return view('manage_utility', ['client_details' => $clients]);
    }
}

below is what I did in my routes

Route::get('/manage_utility', function () {
    return view('manage_utility');
});

Route::get('statistics/', 'UtilityManagementController@index')->name('index');

below is my blade file

div class="container" style="margin-top: 7%;"> 
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>ID Number</th>
                    <th>Client Name</th>
                    <th>Phone Number</th>
                    <th>Address </th>
                    <th>Float Amount</th>
                    <th>Actions</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($client_details as $item)
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>
                            <a href="" class="btn btn-primary" data-toggle="modal" data-target="">Edit</a>
                            <a href="" class="btn btn-danger" data-action="" data-toggle="modal" data-target="">Delete</a>    
                        </td>
                    </tr> 
                @endforeach 
                </tbody> 
            </table>
            <div class="d-flex">
            {!! $client_details->links('pagination::bootstrap-4') !!}
            </div> 


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/HnfPOJ4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire