My application is developed in Laravel 5.1. Can I use Billing module of laravel from 5.2 ? I have seen in 5.2 the billing module is quite different and demands different namespaces and interfaces. I have tried to use by upgrading cashier package to ~6.0 but it has generated error
Error Output: PHP Fatal error: Interface 'Laravel\Cashier\Contracts\Billable' not found in /project/app/Models/User.php on line 8
In Laravel 5.1 with cashier 4.0,
this is how my User Model have following namespaces
<?php namespace App\Models;
use Cartalyst\Sentinel\Users\EloquentUser;
use Laravel\Cashier\Billable;
use Laravel\Cashier\Contracts\Billable as BillableContract;
class User extends EloquentUser implements BillableContract
{
use Billable;
/////
}
But when I have upgraded cashier to ~6.0 it has generated the above mentioned error.
Can we use cashier package of Laravel 5.2 in 5.1, If yes how can I do that?
The dependencies for Cashier 6.0 don't exceed the requirements that Laravel 5.1 can offer, according to the library's composer.json file, so you should be able to use Cashier 6.0 with Laravel 5.1. The solution here looks to be very simple, just remove the line with the contract:
use Laravel\Cashier\Contracts\Billable as BillableContract;
And use only the Billable trait:
use Laravel\Cashier\Billable;
That's because while Cashier 5.0 had the Billable interface defined in Contracts, version 6.0 removed that. Also the Cashier Documentation for Laravel 5.1 shows how to setup models with Cashier 5 by adding both use statements that you're currently using, while the Cashier Documentation for Laravel 5.2, which uses Cashier 6, only shows that you need to use the Billable trait.
There's also one other notable difference between Cashier 4 and 6 dependencies:
"stripe/stripe-php": "~1.9""stripe/stripe-php": "~3.0"So make sure that requirement is also satisfied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With