'Class 'App\Http\Controllers\Url' 未找到' -- Laravel 5

'Class 'App\Http\Controllers\Url' not found' -- Laravel 5

我开始学习了Laravel 5。正在关注 this tutorial。我收到此错误。 (Class 'App\Http\Controllers\Url' not found)。
我在这里附上了我的代码图片。



Whoops, looks like something went wrong.

1/1
FatalErrorException in UrlController.php line 22:
Class 'App\Http\Controllers\Url' not found
in UrlController.php line 22
at FatalErrorException->__construct() in compiled.php line 1838
at HandleExceptions->fatalExceptionFromError() in compiled.php line 1833
at HandleExceptions->handleShutdown() in compiled.php line 0
at UrlController->store() in compiled.php line 8504
at call_user_func_array:{C:\wamp\www\readit-later\vendor\compiled.php:8504}() in compiled.php line 8504
at Controller->callAction() in compiled.php line 8572
at ControllerDispatcher->call() in compiled.php line 8551
at ControllerDispatcher->Illuminate\Routing\{closure}() in compiled.php line 9190



帮帮我。

您应该使用名称 Url 或任何最适合您的应用程序文件夹中的名称创建一个模型,您也可以通过 artisan 命令

生成一个 url 模型
php artisan make:model Url

或者您可以手动创建一个,例如

<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder;

protected $table = 'table_name' // in case your table name is different than plural of model name

class Url extends Model
{

}

然后在您的控制器中使用此 Url 模型,例如

use App\Url;

然后你就可以使用

$url = new Url;
$url->url = Request::get('url'); //make sure you have used use Illuminate\Http\Request; in starting of your controller 

在控制器中添加

use URL;