gerardojbaez / laraplans Goto Github PK
View Code? Open in Web Editor NEWSaaS style recurring plans for Laravel.
Home Page: http://laraplans.readthedocs.io
License: MIT License
SaaS style recurring plans for Laravel.
Home Page: http://laraplans.readthedocs.io
License: MIT License
judging from the code :
/** * Check if plan is free. * * @return boolean */ public function isFree() { return ($this->price === 0.00 OR $this->price < 0.00); }
it will always return false since $this->price is cast as string while 0.00 is not considered as string
getting this while trying to record feature usage:
$this->report->user->subscriptionUsage('main')->record('credits', $credits_used);
the full error and stack trace:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-credits' for key 'plan_subscription_usages_subscription_id_code_unique' in /home/yahav/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:142
Stack trace:
0 /home/yahav/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(142): PDOStatement->execute(NULL)
1 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(458): Doctrine\DBAL\Driver\PDOStatement->execute()
2 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(657): Illuminate\Database\Connection->Illuminate\Database{closure}('insert intopl...', Array) 3 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('insert into
pl...', Array, Object(Closure))
4 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): Illuminate\Database\Connection->run('insert intopl...', Array, Object(Closure)) 5 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): Illuminate\Database\Connection->statement('insert into
pl...', Array)
6 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert intopl...', Array) 7 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2494): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into
pl...', Array, 'id')
8 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1283): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')
9 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(787): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)
10 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(752): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)
11 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(615): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
12 /home/yahav/www/project/vendor/gerardojbaez/laraplans/src/Laraplans/SubscriptionUsageManager.php(59): Illuminate\Database\Eloquent\Model->save()
13 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(157): Gerardojbaez\Laraplans\SubscriptionUsageManager->record(Object(Gerardojbaez\Laraplans\Feature), 242328)
14 /home/yahav/www/project/app/Classes/Platforms/Processors/YoutubeProcessor.php(156): App\Jobs\ProcessReportJob->saveCreditUsage(242328)
15 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(171): App\Classes\Platforms\Processors\YoutubeProcessor->process()
16 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(108): App\Jobs\ProcessReportJob->processJob()
17 [internal function]: App\Jobs\ProcessReportJob->handle()
18 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
19 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
20 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
21 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
22 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
23 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(App\Jobs\ProcessReportJob))
24 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\ProcessReportJob))
25 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
26 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\ProcessReportJob), false)
27 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\BeanstalkdJob), Array)
28 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(322): Illuminate\Queue\Jobs\Job->fire()
29 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(272): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), Object(Illuminate\Queue\WorkerOptions))
30 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\BeanstalkdJob), 'beanstalkd', Object(Illuminate\Queue\WorkerOptions))
31 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('beanstalkd', 'reportProcessin...', Object(Illuminate\Queue\WorkerOptions))
32 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'reportProcessin...')
33 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
34 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
35 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
36 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
37 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
38 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(184): Illuminate\Container\Container->call(Array)
39 /home/yahav/www/project/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
40 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(171): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
41 /home/yahav/www/project/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
42 /home/yahav/www/project/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
43 /home/yahav/www/project/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
44 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
45 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
46 /home/yahav/www/project/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
47 {main}Next Doctrine\DBAL\Driver\PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-credits' for key 'plan_subscription_usages_subscription_id_code_unique' in /home/yahav/www/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:144
Stack trace:
0 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(458): Doctrine\DBAL\Driver\PDOStatement->execute()
1 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(657): Illuminate\Database\Connection->Illuminate\Database{closure}('insert intopl...', Array) 2 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('insert into
pl...', Array, Object(Closure))
3 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): Illuminate\Database\Connection->run('insert intopl...', Array, Object(Closure)) 4 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): Illuminate\Database\Connection->statement('insert into
pl...', Array)
5 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert intopl...', Array) 6 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2494): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into
pl...', Array, 'id')
7 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1283): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')
8 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(787): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)
9 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(752): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)
10 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(615): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
11 /home/yahav/www/project/vendor/gerardojbaez/laraplans/src/Laraplans/SubscriptionUsageManager.php(59): Illuminate\Database\Eloquent\Model->save()
12 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(157): Gerardojbaez\Laraplans\SubscriptionUsageManager->record(Object(Gerardojbaez\Laraplans\Feature), 242328)
13 /home/yahav/www/project/app/Classes/Platforms/Processors/YoutubeProcessor.php(156): App\Jobs\ProcessReportJob->saveCreditUsage(242328)
14 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(171): App\Classes\Platforms\Processors\YoutubeProcessor->process()
15 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(108): App\Jobs\ProcessReportJob->processJob()
16 [internal function]: App\Jobs\ProcessReportJob->handle()
17 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
18 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
19 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
20 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
21 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
22 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(App\Jobs\ProcessReportJob))
23 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\ProcessReportJob))
24 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
25 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\ProcessReportJob), false)
26 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\BeanstalkdJob), Array)
27 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(322): Illuminate\Queue\Jobs\Job->fire()
28 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(272): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), Object(Illuminate\Queue\WorkerOptions))
29 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\BeanstalkdJob), 'beanstalkd', Object(Illuminate\Queue\WorkerOptions))
30 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('beanstalkd', 'reportProcessin...', Object(Illuminate\Queue\WorkerOptions))
31 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'reportProcessin...')
32 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
33 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
34 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
35 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
36 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
37 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(184): Illuminate\Container\Container->call(Array)
38 /home/yahav/www/project/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
39 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(171): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
40 /home/yahav/www/project/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
41 /home/yahav/www/project/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
42 /home/yahav/www/project/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
43 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
44 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
45 /home/yahav/www/project/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
46 {main}Next Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-credits' for key 'plan_subscription_usages_subscription_id_code_unique' (SQL: insert into
plan_subscription_usages
(code
,subscription_id
,used
,updated_at
,created_at
) values (credits, 1, 242328, 2018-09-11 12:17:11, 2018-09-11 12:17:11)) in /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
Stack trace:
0 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('insert intopl...', Array, Object(Closure)) 1 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(459): Illuminate\Database\Connection->run('insert into
pl...', Array, Object(Closure))
2 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php(411): Illuminate\Database\Connection->statement('insert intopl...', Array) 3 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert into
pl...', Array)
4 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2494): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into `pl...', Array, 'id')
5 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1283): Illuminate\Database\Query\Builder->insertGetId(Array, 'id')
6 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(787): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)
7 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(752): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)
8 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(615): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
9 /home/yahav/www/project/vendor/gerardojbaez/laraplans/src/Laraplans/SubscriptionUsageManager.php(59): Illuminate\Database\Eloquent\Model->save()
10 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(157): Gerardojbaez\Laraplans\SubscriptionUsageManager->record(Object(Gerardojbaez\Laraplans\Feature), 242328)
11 /home/yahav/www/project/app/Classes/Platforms/Processors/YoutubeProcessor.php(156): App\Jobs\ProcessReportJob->saveCreditUsage(242328)
12 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(171): App\Classes\Platforms\Processors\YoutubeProcessor->process()
13 /home/yahav/www/project/app/Jobs/ProcessReportJob.php(108): App\Jobs\ProcessReportJob->processJob()
14 [internal function]: App\Jobs\ProcessReportJob->handle()
15 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
16 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
17 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
18 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
19 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
20 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(App\Jobs\ProcessReportJob))
21 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\ProcessReportJob))
22 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
23 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\ProcessReportJob), false)
24 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(83): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\BeanstalkdJob), Array)
25 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(322): Illuminate\Queue\Jobs\Job->fire()
26 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(272): Illuminate\Queue\Worker->process('beanstalkd', Object(Illuminate\Queue\Jobs\BeanstalkdJob), Object(Illuminate\Queue\WorkerOptions))
27 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\BeanstalkdJob), 'beanstalkd', Object(Illuminate\Queue\WorkerOptions))
28 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('beanstalkd', 'reportProcessin...', Object(Illuminate\Queue\WorkerOptions))
29 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('beanstalkd', 'reportProcessin...')
30 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
31 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
32 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
33 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
34 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
35 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(184): Illuminate\Container\Container->call(Array)
36 /home/yahav/www/project/vendor/symfony/console/Command/Command.php(251): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
37 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Command.php(171): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
38 /home/yahav/www/project/vendor/symfony/console/Application.php(886): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
39 /home/yahav/www/project/vendor/symfony/console/Application.php(262): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
40 /home/yahav/www/project/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
41 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
42 /home/yahav/www/project/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
43 /home/yahav/www/project/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
44 {main}
Any idea what went wrong?
Pretty simply, many times there will be a free plan which doesn't expire and will not get any event such as payment received to trigger a renewal.
Mainly because the method does not check $this->canceled()
.
Is this intended behavior?
Could you please add carbon 2 to your package instead carbon 1?
Hi guys,
Are you going to support this library in the future?
Thanks,
Siarhei
When I run the faker from UsersTableSeeder I get the following error
Trait method subscription has not been applied, because there are collisions with other trait methods on App\Models\User
Hello guys. Its possible add a custom field in table plan?
Is there anyone who created a fork which support laravel v6.*?
Hi,
in my application users should be able to subscribe to a montly plan and the subscription should get renewed every month until they cancel.
The workflow should be like:
I found the renew()
method but this will reset the feature usage data, which is not what I want. Or should I consider every month as a new subscription?
in laravel 5.5 not working, can you update plz
Invalid plan feature: tempore
tempore exist in database
Don't pass in Feature.php
lines:
41. if (!self::isValid($feature_code)) {
42 throw new InvalidPlanFeatureException($feature_code);
43 }
Laravel 5.6
Subscriptions uses three different status, i.e.: active
, canceled
and ended
but the last one is missing.
Imagine you have a list of plans and want to display the name of the plan, the price and the amount of pictures a user can upload pro plan.
Title | Price | Amount of pictures |
---|---|---|
Basic | 0.00 | 10 |
Pro | 10.00 | 20 |
The Features were created like this:
$planBasic = Plan::create([
'name' => 'Basic',
'price' => 0.00,
]);
$planBasic->features()->save(
new PlanFeature(['code' => 'amount_of_pics', 'value' => 10, 'sort_order' => 1])
);
$planPro = Plan::create([
'name' => 'Pro',
'price' => 10.00,
]);
$planPro->features()->save(
new PlanFeature(['code' => 'amount_of_pics', 'value' => 20, 'sort_order' => 2])
);
It would be nice to have a method at the plan model which returns the value of a feature found by its code. Here is my implementation and usage:
/**
* @return integer
*/
public function getPicturesAttribute() : int
{
return (int) $this->getFeatureByCode('amount_of_pics')->value;
}
/**
* @param String $code
* @return PlanFeature
*/
public function getFeatureByCode(String $code) : PlanFeature
{
return $this->features()->getEager()->first(function($item) use ($code) {
return $item->code === $code;
});
}
If you interested in this, I'll open a PR.
Your requirements could not be resolved to an installable set of packages.
Problem 1 - Installation request for gerardojbaez/laraplans ^2.2 -> satisfiable by gerardojbaez/laraplans[v2.2.0]. - gerardojbaez/laraplans v2.2.0 requires nesbot/carbon ~1.21 -> satisfiable by nesbot/carbon[1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2] but these conflict with your requirements or minimum-stability.
Will be a better approach to use abstract model classes and model interfaces instead of using real models in the package. This will force the developer to implement their own models that extends and implements the base abstract class.
This is helpful in cases where the developer wants to apply different logics to each model. A good example is the Plan model, for multilingual applications, this model needs to be translated.
The current approach works, but IMHO this new alternative is a better fit.
Any suggestions are welcome!
Just a simple question, does this package allows one user to have multiple subscriptions?
Thanks in advance!
In the documentation is isOnTrial() but the method is onTrial() to returno if is on trial or not
Trait method newSubscription has not been applied, because there are collisions with other trait methods on App\User
User Model
use Laravel\Cashier\Billable;
use Illuminate\Notifications\Notifiable;
use Lexx\ChatMessenger\Traits\Messagable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
use Gerardojbaez\Laraplans\Contracts\PlanSubscriberInterface;
use Gerardojbaez\Laraplans\Traits\PlanSubscriber;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements PlanSubscriberInterface
{
use PlanSubscriber, Notifiable, EntrustUserTrait, Billable, Messagable;
}
The conflict is with Cashier, can it be solved?
Hi guys,
Someone can explain what is the usage/differences of:
PlanSubscription "ends_at" attribute and PlanSubscriptionUsage "valid_until" attribute.
I understood that the PlanSubscription talks about the subscription itself when the PlanSubscriptionUsage talks about the usage but I didn't understand the "usage" thing...
Please someone can explain by example.
Thank you very much for the package and time saving!
Leo.
I propose the renaming of the following methods from PlanSubscription
:
active()
to isActive()
onTrial()
to isOnTrial()
canceled()
to isCanceled()
ended()
to hasEnded()
This has two reasons:
is
or has
scopeCanceled()
which will be used like this:$canceledSubscriptions = Subscription::canceled()->get();
I can not do that currently because of the canceled()
method. This will be called instead of the scope.
This is a BC break.
The method (byUser) in the PlanSubscription model has the wrong reference to the database column,
You used user_id instead of subscribable_id
It's on line 317 in the PlanSubscription model, please fix this in your next update.
I'll share with you how I'm using the package when I'm done with my project.
Thanks.
Let use this thread for feedback and suggestions!
Feel free to share how you are using Laraplans package, what features you liked more or what you think is missing!
Please note: Keep this thread for feedback only. Please open a New Issue for bugs reports, feature requests, or anything not related to this thread.
Currently the naming of resettable
is named as both reseteable
and resetable
.
May be breaking change though, so recommend for v2.0.0
Is there any maintained alternative package to manage plan features?
Hi,
when i try this code:
$user = Auth::user();
$plan = Plan::where('name','Test')->first();
$user->newSubscription('lorem ipsum', $plan)->create();
i get an exception:
Call to undefined method Illuminate\Events\Dispatcher::fire() {"userId":1,"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to undefined method Illuminate\Events\Dispatcher::fire() at /var/www/html/xxx/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237) ...........
What can we do to solve this problem? Is fire a deprecated method?
I'm using laravel 5.8.
Thanks
In instance, if you have a Pro plan and lets the user to have unlimited usage of your feature.
@gerardojbaez There is a bug with features reset dates. Reset dates should never be set before today.
If a user subscribes to a yearly plan, uses a feature monthly resettable feature in January, and uses it again on April, the code to regenerate the feature reset date is not correct. It will generate a reset date 1 month after on the first use, then regenerate the date 1 month after on the second use, etc.
I'm submitting the PR (with tests) now.
Laravel 5.4
When
$user->newSubscription('main', $plan)->create();
I get error.
Please see description: czechbox#7
What is the use for the sort_order field used in Plan and PlanFeature?
Error "Invalid plan feature: listings". When using "$user->subscriptionUsage('main')->record('listings', 2)"
Hi,
First of all, thanks for great package, it saved a lot of time.
When I created a new subscription, both SubscriptionCreated and SubscriptionPlanChanged events are fired. Shouldn't it be just SubscriptionCreated event?
Normally, I expect SubscriptionPlanChanged event fired when change of existing subscription.
The doc says:
The first argument passed to newSubscription method should be the name of the subscription. If your application offer a single subscription, you might call this main or primary. The second argument is the plan instance your user is subscribing to.
In my scenario I have multiple plans where a user can subscribe to. He can only subscribe to one plan at a time, so he will never have more than one subscription. Does this means, the name of the subscription can be just primary
?
If the feature value is not numeric or not one of the positive words, you get this error below when using canUse()
ErrorException in SubscriptionAbility.php line 83:
A non-numeric value encountered
in Container.php (line 910)
Here is the code:
public function index()
{
$user = Auth::user();
$plan = Plan::find(1);
$user->newSubscription('main', $plan)->create();
}
I added use Gerardojbaez\Laraplans\Models\Plan; in beginning of the controller but it never worked. Could you please help me?
When executing the following code:
$user = Auth::user(); $plan = Plan::find(1); $user->newSubscription('Free', $plan)->create();
I'm getting the following errors:
Illuminate \ Database \ QueryException (22007) SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2117-03-21 15:18:06' for column 'ends_at' at row 1 (SQL: insert into
plan_subscriptions (
plan_id,
trial_ends_at,
name,
subscribable_id,
subscribable_type,
starts_at,
ends_at,
updated_at,
created_at) values (1, , Free, 1, App\Models\User, 2018-03-21 15:18:06, 2117-03-21 15:18:06, 2018-03-21 15:18:06, 2018-03-21 15:18:06))
/**
* Find ending subscriptions.
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeFindEndingPeriod($query, $dayRange = 3)
{
$from = Carbon::now();
$to = Carbon::now()->addDays($dayRange);
$query->whereBetween('ends_at', [$from, $to]);
}
Potential Fix: -->
public function scopeFindEndingPeriod($query, $dayRange = 3)
{
$from = Carbon::now();
$to = Carbon::now()->addDays($dayRange);
$query->whereBetween('ends_at', [$from, $to])->whereNull('canceled_at')->whereNull('canceled_immediately');
}
Hi! I'm having an issue with this package. I have succesfully registered 3 plans, each one with a 15 days trial period, but when I register a user with a plan, it doesn't take in count the trial days. For example, I have a user who have a plan that starts at 2019-03-06, the trial ends at 2019-03-21, but it ends at 2019-04-06.
The method I use for register a new subscription is $user->newSubscription($request->plan_name, $plan)->create();
How can I set the trial period succesfully?
Thank you for your help!
Both the traits and migrations directly reference User models, which removes the point of building it into a Trait.
A person may want to integrate their subscriptions on a different kind of Model.
Please change subscription statuses in the documentation:
active
=> isActive
canceled
=> isCanceled
canceledImmediately
=> isCanceledImmediately
ended
=> isEnded
I need to use Mongodb for my laravel project. Is it possible to use Laraplans with jenssegers/mongodb package?
@gerardojbaez it will be better to create an updating guide for newly versions in future or create an update scripts as in laratrust
package.
There are a few breaking changes in new version:
you added canceled_immediately
to 'plan_subscriptions' table;
you changed user_id
in 'plan_subscriptions' to 'morph';
Could you please describe the other possible breaking changes?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.