DB::table() method not found, laravel
I researched the net, but couldnt find a solution to my problem.
I cant get an element from my database.
<?php
namespace App;
use IlluminateSupportFacadesDB;
use IlluminateDatabaseEloquentModel;
use IlluminateSupportFacadesAuth;
class Wishlist extends Model
{
public $table = 'wishlist';
public $fillable = ['book_id','user_id',];
public function books() //one-to-many
{
return $this->hasMany('AppBook');
}
public function user()
{
return $this->belongsTo('AppUser');
}
public static function myWishlist()
{
$id = Auth::id();
$wishlist = DB::table('users')->where('id', $id)->pluck('wishlist_id');
$wishlist_id = User::where('id', $id)->pluck('wishlist_id');
return Book::where('wishlist_id', $wishlist_id);
}
}
If I fill in hard: ‘return Book::where(‘whishlist_id’, 1);’ it shows it correctly. But neither ‘wishlist’ nor ‘wishlist_id’ shows it.
I would be so happy to get help!
from Laravel Questions and Answers https://laravelquestions.com/php/dbtable-method-not-found-laravel/
via Lzo Media
No comments:
Post a Comment