4

I am using vscode when i make a component .. it gives me an error undefined method at layout even if i replace it with extends the intelephense plugin gives me the same error

i installed ide_helper but it didn't work .. however the code works fine as expected


<?php

namespace App\Http\Livewire;


use Livewire\Component;


class AdminGradeComponent extends Component
{

  public function render()
  {
    return view('livewire.home-component')->layout('layouts.app'); //error here at layout
  }
}
John Deck
  • 787
  • 1
  • 12
  • 27

3 Answers3

3

Source https://github.com/bmewburn/vscode-intelephense/issues/2079.

The view() return type is an interface that does not declare the layout method.
Create a file in the root directory of you application, like this:

<?php
  namespace Illuminate\Contracts\View;
  use Illuminate\Contracts\Support\Renderable;    
  interface View extends Renderable
  {
    /** @return static */
    public function extends();
    public function layoutData();
    public function layout();
    //any other method that throws false error here :)
  }
?>
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

here you need to close the round bracket...it´s missing

view('livewire.home-component'->

UPDATED: then nevermind it...I'm also facing this in JB enter image description here

Prospero
  • 2,190
  • 2
  • 4
  • 18
-1

If you have a PHP Intelephense extension enable in your vscode then try to disable it.