cyrildewit / eloquent-viewable

Associate views with Eloquent models in Laravel
MIT License
803 stars 104 forks source link

CyrildeWit\EloquentViewable\Views::forViewable(): Argument #1 ($viewable) must be of type #288

Closed vanji-code closed 8 months ago

vanji-code commented 1 year ago

Description:

When I use add record(); it shows,

"TypeError CyrildeWit\EloquentViewable\Views::forViewable(): Argument #1 ($viewable) must be of type CyrildeWit\EloquentViewable\Contracts\Viewable, Illuminate\Database\Eloquent\Collection given, called in C:\xampp\htdocs\witneer\vendor\cyrildewit\eloquent-viewable\src\helpers.php on line 26,"

pls do needful,

Steps To Reproduce:

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Expected behavior:

[What you expected to happen]

Actual behavior:

"TypeError CyrildeWit\EloquentViewable\Views::forViewable(): Argument #1 ($viewable) must be of type CyrildeWit\EloquentViewable\Contracts\Viewable, Illuminate\Database\Eloquent\Collection given, called in C:\xampp\htdocs\witneer\vendor\cyrildewit\eloquent-viewable\src\helpers.php on line 26" Screenshot 2023-05-05 220440

cyrildewit commented 1 year ago

You din't paste your code, so how would I or anyone else be able to see what's going on? I think you forgot to add the Viewable interface to your model. See the docs on how to do this.