使用 tinker 能操纵数据,但用 controller 操纵却报错,求大神解答?
今天在琢磨结合Neo4J和Laravel开发应用,但在操纵数据的时候,通过tinker都能正常保存,读取和删除数据,但用controller的时候却报错,求大神帮忙解答。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PostController extends Controller
{
public function index()
{
$posts = \App\Post::orderBy('created_at', 'desc')->get();
return view('post/index', compact('posts'));
}
Post的Model
<?php
namespace App;
use Vinelab\NeoEloquent\Eloquent\Model;
class Post extends Model
{
}
报错信息:
Argument 1 passed to Vinelab\NeoEloquent\Query\Builder::__construct() must be an instance of Vinelab\NeoEloquent\Connection, instance of Illuminate\Database\MySqlConnection given, called in C:\wamp\www\blog\test\vendor\vinelab\neoeloquent\src\Vinelab\NeoEloquent\Eloquent\Model.php on line 75 and defined
tinker操纵信息:
>>> $posts = \App\Post::orderBy('created_at', 'desc')->get();
=> Illuminate\Database\Eloquent\Collection {#759
all: [
App\Post {#763
updated_at: "2017-12-14 16:13:16",
created_at: "2017-12-14 07:37:02",
title: "this is modify post1",
content: "this is post1 content",
id: 61,
},
],
}
>>>
推荐文章: