Open virsoni opened 7 years ago
can anybody reply on this plz?
# ### can anybody reply on my issue please ? @Turaylon @it-can @pvdptje @Beaudinn @darryldecode
You could do it like this: app('wishlist')->add(..)
.
You could also make a new facade for the wishlist, like this:
And place this facade in your app.php config file. Now you could do something like Wishlist::add(..);
You can create your own custom facade. Example you can create a Wishlist Facade putting in a file like app/Facades/Wishlist.php
and put this code:
<?php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class Wishlist extends Facade{
protected static function getFacadeAccessor() { return 'wishlist'; }
}
Add in tour config/app.php the following line:
'Wishlist' => App\Facades\Wishlist::class
and then you can use all the function of the cart on your custom Wishlist Facade like this:
\Wishlist::add('1','test', '0', 1);
Thanks for your replies I will try it out.. soon :)
Hi
I have placed the code as under but when I call \Wishlist::add('1','test', '0', 1); its not working.
<?php
namespace App\Facades; use Illuminate\Support\Facades\Facade;
class Wishlist extends Facade{ protected static function getFacadeAccessor() { return 'wishlist'; } } Add in tour config/app.php the following line: 'Wishlist' => App\Facades\Wishlist::class
getting below issue when call \Wishlist::add('1','test', '0', 1); FatalThrowableError in Facade.php line 223: Call to undefined method App\Facades\Wishlist::add() @Turaylon @pvdptje
That's odd. What happens when you try this:
app('wishlist')->add(...)'
?
Call to undefined method App\Facades\Wishlist::add()
same issue display.
Where exactly I have to place below code and how? app('wishlist')->add(...)' ? @pvdptje
Call to undefined method App\Facades\Wishlist::add()
same issue display.
Where exactly I have to place below code and how? app('wishlist')->add(...)' ? @Turaylon @pvdptje
On the place where you want to add something to your wishlist. Instead of using the facade, you use app('wishlist')
to access the wishlist directly.
I have tried as you said but its not working yet can you please check attached screenshots of code I used and provide your steps again if possible?
getting below error now when execute order app_wishlist_code.png screenshot's line of code. Call to undefined method Darryldecode\Cart\Facades\CartFacade::add() @pvdptje @Turaylon
https://cloud.githubusercontent.com/assets/16146696/18581319/af89d574-7c1d-11e6-9a46-6ab3107777c2.png https://cloud.githubusercontent.com/assets/16146696/18581298/97c8eb00-7c1d-11e6-9c4c-91a8df624ffd.png
I have tried as you said but its not working yet can you please check attached screenshots of code I used and provide your steps again if possible?
getting below error now when execute order app_wishlist_code.png screenshot's line of code. Call to undefined method Darryldecode\Cart\Facades\CartFacade::add()
@pvdptje @Turaylon
In your service provider, you instantiate a new Cart class. Is this the actual Cart class or the facade class?
Yes its actual Cart class of Darryldecode.
The error references to the CartFacade from the package. You did make your own facade if i'm correct. So there's something going wrong there.
If you can grant me access to your repository, i can check when i'm home.
Also, calling app('wishlist')
will never produce this error: Call to undefined method Darryldecode\Cart\Facades\CartFacade::add()
, because you are not calling a facade.
Hi
I have placed below code in Appserviceprovider > register method.
How can i Add product in wishlist cart like this \Cart::add('1','test', '0', 1); ?