这是我的AuthorController.php
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use App\Models\Author;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
use Illuminate\Support\Facades\Redirect;
use View;
use Input;
class AuthorController extends Controller {
public function index()
{
$author_name = Input::get('name');
$author_slug = Input::get('slug');
$author_bio = Input::get('bio');
$new_author = Author::create(array('name' => $author_name, 'slug' => $author_slug, 'bio' => $author_bio));
return Redirect::to('/');
}
}
?>
这是我的路线文件中的内容
Route::post('/create-author', [
'as' => 'create-author',
'uses' => 'AuthorController@index'
]);
我不太确定是什么问题,我尝试使用$new_author = Author::create(array('name' => 'John));
将某些东西硬编码到数据库中并且它有效,它是否是Input类相对于AuthorController.php的目录,这是在App\Controllers
答案 0 :(得分:1)
在控制器中使用它,
use Illuminate\Support\Facades\Input;
答案 1 :(得分:0)
每次要使用预定义类时,都可以在 config / app.php 中看到为其定义的别名。你应该只使用via facade,
use Illuminate\Support\Facades\Input;