Code Monkey home page Code Monkey logo

laraplans's People

Contributors

acen avatar adibnaya avatar bgultekin avatar gerardojbaez avatar konafets avatar richardkeep avatar rifan75 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laraplans's Issues

Method isFree will always return false

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

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-credits' for key 'plan_subscription_usages_subscription_id_code_unique'

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 into pl...', 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 into pl...', 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 into pl...', 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 into pl...', 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 into pl...', 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 into pl...', 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 into pl...', 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 into pl...', 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?

Carbon 2?

Could you please add carbon 2 to your package instead carbon 1?

Further maintaining

Hi guys,

Are you going to support this library in the future?

Thanks,
Siarhei

Error when running UsersTableSeeder

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

Best practise to create a continous subscription

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:

  1. User subscribes to ProPlan
  2. User gets the ability to use the ProPlans features
  3. User gets invoiced (not part of the package but belongs to the workflow)
  4. User uses the service for one month
  5. Subscription of the user gets renewed (end date is set to next month)
  6. User gets a new invoice
    ...
    N. User cancels the plan
    N+1. Subscription is valid until end of the interval
    N+2. After subscription endet, User falls back to BasicPlan

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?

Add methods to plan to retrieve informations about the features

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.

Carbon package version needs update in composer

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.

Use Abstract models and interfaces instead of optional configurable models

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!

PHP Fatal error: Trait method newSubscription has not been applied

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?

Question - valid_until vs ends_at

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.

BC: Rename boolean methods of PlanSubscription

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:

  1. It is a convention to have these kind of methods prefixed with is or has
  2. The current naming interferres with the scope feature. I want to create a scope 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.

Wrong plan subscription column reference for user

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.

Feedback: How are you using Laraplans?

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.

undefined method Illuminate\Events\Dispatcher::fire()

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

Bug with features reset date, they should always be generated after now.

@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.

Support for laravel 5.7

Error "Invalid plan feature: listings". When using "$user->subscriptionUsage('main')->record('listings', 2)"

SubscriptionPlanChanged event confusion

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.

Purpose of the subscriptions name property

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?

A non-numeric value encountered

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

BindingResolutionException

Here is the error:
BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ $user ]] in class Gerardojbaez\Laraplans\SubscriptionBuilder

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?

Can't subscribe user to plan

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))

FindEndingPeriod does not account for canceled subscription

/**
* 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');
}

Trial is not working

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!

Plan Subscriber forced to be `User`

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.

Update subscription statuses in readme

Please change subscription statuses in the documentation:
active => isActive
canceled => isCanceled
canceledImmediately => isCanceledImmediately
ended => isEnded

Updating guide for new version

@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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.