mardi 25 juin 2019

Undefined variable: errors in laravel foreach

I'm trying to retrieve data from database into my Laravel CRUD, but it says undefined variable in my view.

Here's the view frame.blade.php

@foreach($mahasiswa as $mhs)
   <tr>
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td><a onclick="event.preventDefault();editmhsForm();" href="#" class="edit open-modal" data-toggle="modal" value=""><i class="material-icons" data-toggle="tooltip" title="Edit">&#xE254;</i></a>
           <a onclick="event.preventDefault();deletemhsForm();" href="#" class="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete">&#xE872;</i></a>
       </td>
       </tr>
@endforeach

Here's the controller

use App\Dashboard;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class DashboardController extends Controller
{

public function index(Request $request)
{
    $mhs = Dashboard::orderBy('id', 'desc')->paginate(5);

    return view('frame')->with('frame', $mhs);
}

And here's the route

Route::group(['prefix' => 'mahasiswa'], function () {
    Route::get('/dashboard/{id}', [
        'uses' => 'DashboardController@show',
        'as'   => 'mahasiswa.show',
    ]);

    Route::post('/dashboard/', [
        'uses' => 'DashboardController@store',
        'as'   => 'mahasiswa.store',
    ]);

    Route::put('/dashboard/{id}', [
        'uses' => 'DashboardController@update',
        'as'   => 'mahasiswa.update',
    ]);

    Route::delete('/dashboard/{id}', [
        'uses' => 'DashboardController@destroy',
        'as'   => 'mahasiswa.destroy',
    ]);
});

I keep getting "Undefined variable: mahasiswa" on my view

Does anyone know the reason for this?



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

Aucun commentaire:

Enregistrer un commentaire