T
T
Twelfth Doctor2017-06-26 16:31:51
Laravel
Twelfth Doctor, 2017-06-26 16:31:51

Why are query builder methods not available for Eloquent models?

Hello! There is a model:

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
 * @property integer $unid
 * @property integer $userid
 * @property integer $domain
 * @property string $host
 * @property string $type
 * @property string $content
 * @property integer $priority
 * @property integer $weight
 * @property integer $proto
 * @property integer $port
 * @property integer $target
 */
class DNS extends Model
{
    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'dns';
    protected $primaryKey = 'unid';
    /**
     * @var array
     */
    protected $fillable = ['userid', 'domain', 'host', 'type', 'content', 'priority', 'weight', 'proto', 'port', 'target'];
}

And controller:
namespace App\Http\Controllers;
require '../vendor/autoload.php';
use App\DNS;

class DNSController extends Controller
{ 
//тут какой-то код
....
//а тут я пытаюсь использовать методы из конструктора запросов  в модели 
  public function CheckRecord ($userid,$id) {
$check = new DNS();
$check->where('unid',1);
        if (isset($check->content)) {return true;}
        else {return false;}
    }
...

}

But PHPstorm says that there are no where and find functions in this class, but it found the functions isUnguarded, all, destroy, save, etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2017-06-27
@AmdY

These are all facades and magic methods, install https://github.com/barryvdh/laravel-ide-helper

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question