first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
<?php
namespace Database\Seeders;
use Common\Billing\BillingPlan;
use Common\Billing\Models\Product;
use Common\Billing\Products\Actions\CrupdateProduct;
use Illuminate\Database\Seeder;
class BillingPlanSeeder extends Seeder
{
protected array $sharedFeatures = [
'No advertisements',
'Watch on laptop, TV, phone and tablet',
'Unlimited movies and TV shows',
'Cancel anytime',
'First month free',
];
public function run(): void
{
if (!Product::count()) {
$this->basicPlan();
$this->standardPlan();
$this->proPlan();
}
}
protected function basicPlan(): void
{
app(CrupdateProduct::class)->execute([
'name' => 'Basic',
'amount' => 7.99,
'position' => 1,
'feature_list' => [
...$this->sharedFeatures,
'1 screen(s) at the same time',
],
'prices' => [
[
'amount' => 7.99,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 1,
],
[
'amount' => 76.70,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 12,
],
],
]);
}
protected function standardPlan(): void
{
app(CrupdateProduct::class)->execute([
'name' => 'Standard',
'position' => 2,
'recommended' => true,
'feature_list' => [
...$this->sharedFeatures,
'2 screen(s) at the same time',
'HD available',
],
'prices' => [
[
'amount' => 9.99,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 1,
],
[
'amount' => 95.90,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 12,
],
],
]);
}
protected function proPlan(): void
{
app(CrupdateProduct::class)->execute([
'name' => 'Pro',
'position' => 3,
'feature_list' => [
...$this->sharedFeatures,
'4 screen(s) at the same time',
'HD available',
'Ultra HD available',
],
'prices' => [
[
'amount' => 11.99,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 1,
],
[
'amount' => 115.10,
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 12,
],
],
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Seeders;
use App\Models\Channel;
use Common\Channels\GenerateChannelsFromConfig;
use Common\Database\Seeds\DefaultPagesSeeder;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run(): void
{
$this->call(WatchlistSeeder::class);
$this->call(BillingPlanSeeder::class);
$this->call(DefaultPagesSeeder::class);
if (
!config('common.site.demo') &&
Channel::where('type', 'channel')->count() === 0
) {
$homepageChannel = (new GenerateChannelsFromConfig())->execute([
resource_path('defaults/channels/shared-channels.json'),
resource_path('defaults/channels/default-channels.json'),
]);
settings()->save([
'homepage.type' => 'channels',
'homepage.value' => $homepageChannel->id,
]);
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Database\Seeders;
use App\Models\Channel;
use App\Models\User;
use Illuminate\Database\Seeder;
class WatchlistSeeder extends Seeder
{
/**
* Create watchlist for users that don't already have one.
*/
public function run(): void
{
$userIds = app(User::class)
->whereDoesntHave('watchlist')
->pluck('id');
$userIds->each(function($userId) {
Channel::create([
'name' => 'watchlist',
'user_id' => $userId,
'internal' => true,
'public' => false,
'type' => 'list',
'config' => [
'contentType' => 'manual',
'contentOrder' => 'channelables.order:asc',
'contentModel' => 'title',
'layout' => 'grid',
'preventDeletion' => true,
]
]);
});
}
}