无法将数据插入数据库,并且找不到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) 我正在进行登录功能,但遇到了一个我无法弄清楚的错误.
这是我的Model Login类:
class Login {
private $username;
private $password;
private $cxn; //database object
function __construct($username,$password)
{
//set data
$this->setData($username, $password);
//connect DB
$this->connectToDB();
// get Data
}
function setData($username, $password)
{
$this->username = $username;
$this->password = $password;
}
private function connectToDB()
{
include 'Database.php';
$connect = '../include/connect.php';
$this->cxn = new database($connect);
}
function getData()
{
$query = "SELECT * FROM anvandare WHERE anvandarnamn = '$this->username' AND losenord ='$this->'password'";
$sql = mysql_query($query);
if(mysql_num_rows($sql)>0)
{
return true;
}
else
{
throw …Run Code Online (Sandbox Code Playgroud)