In Ordnung, also habe ich meine erste Website mit Laravel eingerichtet und ich bleibe dran, diesen Fehler zu bekommen. Ich versuche gerade, die Indexseite einzurichten (für eine CRUD-App), aber dieser Fehler taucht immer wieder auf.Zeile 5: Aufruf zu undefinierter Funktion link_to_route()
FatalErrorException in 06f534e736fde409cb38fab481f04cd04f7fbca4.php line 5:
Call to undefined function link_to_route()
Meine web.php (Routen):
<?php
Route::get('/', function() {
return view('index');
});
Route::resource('users', 'UserController');
Route::get('/register', '[email protected]');
Route::post('/register', '[email protected]');
Mein usercontroller.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class UserController extends BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$users = User::all();
return View::make('users.index', compact('users'));
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return View::make('users.create');
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
Mein index.blade.php:
@section('main')
<h1>All Users</h1>
<p>{{ link_to_route('users.create', 'Add new user') }}</p>
@if ($users->count())
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Email</th>
<th>Phone</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->username }}</td>
<td>{{ $user->password }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->phone }}</td>
<td>{{ $user->name }}</td>
<td>{{ link_to_route('users.edit', 'Edit', array($user->id), array('class' => 'btn btn-info')) }}</td>
<td>
{{ Form::open(array('method'
=> 'DELETE', 'route' => array('users.destroy', $user->id))) }}
{{ Form::submit('Delete', array('class' => 'btn btn-danger')) }}
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
@else
There are no users
@endif
@stop
Und mein user.blade.php (Layout):
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
FatalErrorException in ProviderRepository.php Linie 146: Class 'Collective \ Html \ HtmlServiceProvider' nicht gefunden –
@Ivannbn Bitte überprüfen Sie diese Anleitung für HTML-Paket https: // laravelcollective. com/docs/5.0/html – aleksejjj