无法将数据插入数据库,并且找不到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) 所以这个问题已经被问了好几次了,但是我还没有找到有效的答案。
我正在使用PhpStorm-2016.3.2和Laravel 5.4
我已经尝试使用https://github.com/barryvdh/laravel-ide-helper以及PhpStorm的Laravel插件。
我尝试检查“在类中存在降级严重性if_magic方法”选项-无法正常工作。
解决此问题的唯一方法是完全关闭未定义方法的警告,但是关闭此类功能将无法使用IDE。
有没有人找到解决这个问题的方法?
资料来源:
https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15