无法将数据插入数据库,并且找不到IDE(phpStrom)中显示的所有查询类和Model类的方法如何解决?
这是我的扩展类(Post.php)这里显示最新的错误和where方法:
<?php namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Post extends Model {
protected $fillable=[
'title',
'description',
'location',
'contact',
'type',
'published_at'
];
protected $date=['published_at'];
public function setPublishedAtAttribute($date)
{
$this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $date);
}
/**
* @param $query
*/
public function scopePublished($query)
{
$query->where('published_at', '<=', Carbon::now());
}
public function scopeUnPublished($query)
{
$query->where('published_at', '>=', Carbon::now());
}
/**
* An post is owned by a user.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user(){
return $this->belongsTo('App\User');
}
}
Run Code Online (Sandbox Code Playgroud)
这是我使用它的Controller类:
<?php namespace App\Http\Controllers;
use …Run Code Online (Sandbox Code Playgroud)