Skip to content

Methods such as orderBy, inRandomOrder, paginate, findOrFail etc. do not appear from Model #55867

Open
@IgorArnaut

Description

@IgorArnaut

Laravel Version

12.14.1

PHP Version

8.4.0

Database Driver & Version

No response

Description

I was watching this tutorial. https://www.youtube.com/playlist?list=PL4cUxeGkcC9gF5Gez17eHcDIxrpVSBuVt

I have written this Ninja model:

class Ninja extends Model
{
    protected $fillable = [
        "name",
        "skill",
        "bio",
        // 19 Handling Post Requests
        "dojo_id"
    ];
    /** @use HasFactory<\Database\Factories\NinjaFactory> */
    use HasFactory;

    // 17 Foreign Keys 2
    public function dojo()
    {
        return $this->belongsTo(Dojo::class);
    }
}

But when I type it's methods, methods orderBy, findOrFail and paginate aren't recognizable in Laravel 12. They do not get suggestions in VS Code. I've checked Model class and these methods don't exist in it. I have the official Laravel extension and PHP Intelephense installed. I assume something has changed in Laravel 12.
Image
Image

I've found a workaround to add method query after the Model name. It works for paginate, findOrFail, but it doesn't work for orderBy, inRandomOrder etc.

public function index()
{
    // route --> /ninjas/
    // 15 Pagination
    $ninjas = Ninja::with("dojo")->orderBy("created_at", "desc")->paginate(10);
    return view("ninjas.index", [
        "ninjas" => $ninjas
    ]);
}

Steps To Reproduce

  1. Create Laravel Project
  2. Create a Ninja model (with flags -mfs)
  3. Create a Ninja controller for the model
  4. Type $ninja = Ninja:: in the controller
  5. Type a method name, e.g. orderBy
  6. It does not appear in suggestions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions