I'm debuting Laravel, and I want to create a dynamic one page app. I'm using Laravel Voyager as an admin package. so I managed to display all the posts Data but when I tried to display the work's, it shows error that he can't find the variable works.
My controller: WorkController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Work;
class WorkController extends Controller
{
/**
* Display the specified resource.
*
* @param string $slug
* @return \Illuminate\Http\Response
*/
public function index()
{
$works = Work::all();
return view('welcome', ['works' => $works]);
}
}
My routes :
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', 'BlogController@index');
Route::get('/work','WorkController@index')->name('work.index');
Route::get('/article/{article}', 'ArticleController@show')->name('article.show');
Route::group(['prefix' => 'admin'], function () {
Voyager::routes();
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
As I mentioned I'm still newbie but I want to know what is my error, Thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire