mercredi 28 octobre 2015

Method 'where' not found in class (PHPStorm) - Laravel 5.1

I'm kind of new to both laravel and PHPStorm. I'm recently working on a project where I have a model and a controller like the following:

Model:

<?php
namespace App\Http\Models;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
    public $timestamps = false;
}

Controller:

<?php

namespace App\Http\Controllers;
use App\Http\Models\Category;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CategoryController extends Controller
{ /*....*/

And when I try to query my database using the Category model inside the controller, I get the 'where' underlines by PHPStorm and saying that the method 'where' is not found in class App\Http\Models\Category:

$default_cat = Category::where("name","=",$category)->first();

I tried almost every solution I could find on the internet, and verified that I got the namespaces right. But nothing fixed it. I even tried to make a composer update command but no result.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire