'Foreach Loop Keeps Giving Me Undefined Variable

I am trying to display a list of records in a table after an upload of an excel file. But whenever i implement the code below it keeps giving me Undefined variable: ManualCpdUpdates. Help is greatly appreciated.

A corresponding controller:

<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Http\Request;
use App\Imports\ImportManualCpdUpdate;
use Illuminate\Support\Facades\Http;
use GuzzleHttp\Client;
use App\Models\ManualCpdUpdate;


class ManualPointsController extends Controller
{
    public function index()
    {
        $manualcpdupdates = ManualCpdUpdate::all();

        return view('admin/rewards/points/manual_update', compact('manualcpdupdates'));
    }

    public function import(Request $request){

        Excel::import(new ImportManualCpdUpdate, $request->file('file')->store('files'));
        return view('admin/rewards/points/manual_update');
    }

And a snippet of Its View:

 <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped font-14">
                                    <tr>
                                        <th>#</th>
                                        <th class="text-left">{{ trans('admin/main.pname') }}</th>
                                        <th class="text-left">{{ trans('admin/main.ccpd_id') }}</th>
                                        <th class="text-left">{{ trans('admin/main.crnumber') }}</th>
                                        <th class="text-left">{{ trans('admin/main.ccsn') }}</th>
                                    </tr>
                                   @foreach($ManualCpdUpdates as $manualcpdupdates)


                                   @endforeach
                                </table>
                            </div>
                        </div>



Solution 1:[1]

your array $manualcpdupdates instead of $Manualcpdupdates variables are case sensitive on PHP

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar Tammam