Browse Source

Store supplier information for services

master
Immanuel Onyeka 3 years ago
parent
commit
ed898fa60b
11 changed files with 196 additions and 49 deletions
  1. +68
    -40
      app/Console/Commands/ServicesInit.php
  2. +63
    -0
      app/Http/Controllers/Supply.php
  3. +17
    -0
      app/Models/Referral.php
  4. +5
    -0
      app/Models/Service.php
  5. +18
    -0
      app/Models/Supplier.php
  6. +15
    -1
      config/services.php
  7. +1
    -1
      database/migrations/2021_05_18_184617_create_services_table.php
  8. +1
    -1
      database/migrations/2021_05_19_185302_create_orders_table.php
  9. +4
    -2
      database/migrations/2021_06_23_145817_create_suppliers_table.php
  10. +3
    -3
      database/migrations/2021_06_24_135121_create_referrals_table.php
  11. +1
    -1
      resources/views/home.blade.php

+ 68
- 40
app/Console/Commands/ServicesInit.php View File

@@ -3,7 +3,10 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

use App\Models\Service;
use App\Http\Controllers\Supply;

class ServicesInit extends Command
{
@@ -31,18 +34,12 @@ class ServicesInit extends Command
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
public function handle() {
$this->youtube();
$this->tiktok();
$this->instagram();
$this->twitter();
$this->tiktok();

}

protected function youtube() {
@@ -50,20 +47,21 @@ class ServicesInit extends Command
$s->name = 'Unique Views';
$s->type = 'views';
$s->site = 'youtube';
$s->supplier = 'smmkings';
$s->supplier_id = 2997;
$s->maximum = 500000;
$s->minimum = 1000;
$s->price = 750;
$s->available = true;
$s->save();

$sup = Supply::smmworld( $s->id, 418);
$s->primary_supplier = $sup->id;
$s->save();

/*
$s = new Service;
$s->name = 'Language Targeted Views';
$s->type = 'views';
$s->site = 'youtube';
$s->supplier = 'smmkings';
$s->modifier = 'language';
$s->maximum = 100000;
$s->minimum = 1000;
@@ -77,7 +75,6 @@ class ServicesInit extends Command
$s = new Service;
$s->name = 'Location Targeted Views';
$s->site = 'youtube';
$s->supplier = 'smmkings';
$s->modifier = 'location';
$s->maximum = 100000;
$s->minimum = 1000;
@@ -94,23 +91,29 @@ class ServicesInit extends Command
$s = new Service;
$s->name = 'Likes';
$s->site = 'youtube';
$s->supplier = 'smmkings';
$s->maximum = 100000;
$s->minimum = 50;
$s->price = 850;
$s->available = true;
$s->save();

$sup = Supply::smmworld($s->id, 385);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Comments';
$s->site = 'youtube';
$s->supplier = 'smmkings';
$s->maximum = 500000;
$s->minimum = 10;
$s->price = 7500;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3726);
$s->primary_supplier = $sup->id;
$s->save();

}

protected function instagram() {
@@ -119,32 +122,34 @@ class ServicesInit extends Command
$s->name = 'Likes with Profile Visits';
$s->type = 'likes';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 2997;
$s->maximum = 500000;
$s->minimum = 1000;
$s->price = 700;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 2997);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Likes';
$s->type = 'likes';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 3775;
$s->maximum = 50000;
$s->minimum = 100;
$s->price = 50;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3775);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Post Impressions';
$s->type = 'impressions';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 618;
$s->maximum = 1000000;
$s->minimum = 100;
$s->price = 100;
@@ -152,42 +157,52 @@ class ServicesInit extends Command
$s->description = 'Post impressions and visits';
$s->save();

$sup = Supply::smmkings($s->id, 618);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Profile Visits';
$s->type = 'profile';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 2997;
$s->maximum = 500000;
$s->minimum = 100;
$s->price = 100;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 2997);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Post Views';
$s->type = 'views';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 2840;
$s->maximum = 10000000;
$s->minimum = 100;
$s->price = 50;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 2840);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Followers';
$s->type = 'followers';
$s->site = 'instagram';
$s->supplier = 'smmkings';
$s->supplier_id = 3882;
$s->maximum = 100000;
$s->minimum = 10;
$s->price = 410;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3882);
$s->primary_supplier = $sup->id;
$s->save();

}

protected function twitter() {
@@ -195,37 +210,44 @@ class ServicesInit extends Command
$s->name = 'Video Views';
$s->type = 'views';
$s->site = 'twitter';
$s->supplier = 'smmkings';
$s->supplier_id = 287;
$s->maximum = 1000000;
$s->minimum = 100;
$s->price = 90;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 287);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Impressions';
$s->type = 'impressions';
$s->site = 'twitter';
$s->supplier = 'smmkings';
$s->supplier_id = 288;
$s->maximum = 1000000;
$s->minimum = 100;
$s->price = 700;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 288);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Followers';
$s->type = 'followers';
$s->site = 'twitter';
$s->supplier = 'smmkings';
$s->supplier_id = 3820;
$s->maximum = 10000;
$s->minimum = 10;
$s->price = 600;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3820);
$s->primary_supplier = $sup->id;
$s->save();

}


@@ -234,39 +256,45 @@ class ServicesInit extends Command
$s->name = 'Views';
$s->type = 'views';
$s->site = 'tiktok';
$s->supplier = 'smmkings';
$s->supplier_id = 3826;
$s->maximum = 10000000;
$s->minimum = 100;
$s->price = 70;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3826);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Likes';
$s->type = 'likes';
$s->site = 'tiktok';
$s->supplier = 'smmkings';
$s->supplier_id = 3935;
$s->maximum = 100000;
$s->minimum = 100;
$s->price = 400;
$s->available = true;
$s->save();

$sup = Supply::smmkings($s->id, 3935);
$s->primary_supplier = $sup->id;
$s->save();

$s = new Service;
$s->name = 'Followers';
$s->type = 'followers';
$s->site = 'tiktok';
$s->supplier = 'smmkings';
$s->supplier_id = 3934;
$s->maximum = 100000;
$s->minimum = 20;
$s->price = 300;
$s->available = true;
$s->save();

}
$sup = Supply::smmkings($s->id, 3934);
$s->primary_supplier = $sup->id;
$s->save();

}

}


+ 63
- 0
app/Http/Controllers/Supply.php View File

@@ -0,0 +1,63 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

use App\Models\Supplier;

class Supply extends Controller
{
// Accepts a site name, service id, and integer/array of supplier rows to
// create

public static function fetch($site) {
return Http::post(config("services.$site.link"), ['key' =>
config("services.$site.key"), 'action' => 'services']);
}

public static function smmkings($service_id, $id) {
$services = Http::post(config("services.smmkings.link"), ['key' =>
config("services.smmkings.key"), 'action' => 'services'])->json();

foreach ($services as $service) {
if ($service['service'] == $id){
$s = new Supplier;
$s->service_id = $service_id;
$s->supplier = 'smmkings';
$s->supplier_id = (int) $service['service'];
$s->supplier_name = $service['name'];
$s->min = (int) $service['min'];
$s->max = (int) $service['max'];
$s->cost = $service['rate'] * 100;
$s->save();
return $s;
}
}
}

public static function smmworld($service_id, $id) {
$services = Http::post(config("services.smmworld.link"), ['key' =>
config("services.smmworld.key"), 'action' => 'services']);
$services = $services['services'];

foreach ($services as $service) {
if ($service['id'] == $id){
$s = new Supplier;
$s->service_id = $service_id;
$s->supplier = 'smmworld';
$s->supplier_id = $service['id'];
$s->supplier_name = $service['name'];
$s->min = $service['min'];
$s->max = $service['max'];
$s->cost = $service['price_per_k'] * 100;
$s->save();
return $s;
}
}
}

}

+ 17
- 0
app/Models/Referral.php View File

@@ -0,0 +1,17 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

use App\Models\User;

class Referral extends Model
{
use HasFactory;

public function users() {
return $this->hasMany(User::class);
}
}

+ 5
- 0
app/Models/Service.php View File

@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Order;
use App\Models\Supplier;

class Service extends Model
{
@@ -18,4 +19,8 @@ class Service extends Model
return $this->hasMany(Order::class);
}

public function suppliers() {
return $this->hasMany(Supplier::class);
}

}

+ 18
- 0
app/Models/Supplier.php View File

@@ -0,0 +1,18 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

use App\Models\Service;

class Supplier extends Model
{
use HasFactory;

public function service() {
return $this->belongsTo(Service::class);
}
}


+ 15
- 1
config/services.php View File

@@ -44,6 +44,20 @@ return [
'pm' => [
'account' => env('PM_ACCOUNT'),
'secret' => env('PM_SECRET'),
]
],

'smmkings' => [
'key' => env('SMM_KEY'),
'link' => env('SMM_LINK'),
],

'getfans' => [
'key' => env('GETFANS_KEY'),
'link' => env('GETFANS_LINK'),
],

'smmworld' => [
'key' => env('SMMWORLD_KEY'),
'link' => env('SMMWORLD_LINK'),
]
];

+ 1
- 1
database/migrations/2021_05_18_184617_create_services_table.php View File

@@ -22,7 +22,7 @@ class CreateServicesTable extends Migration
$table->string('site');
$table->string('note')->nullable();
$table->string('modifier')->default('');
$table->unsignedInteger('primary_supplier');
$table->unsignedInteger('primary_supplier')->nullable();
$table->integer('maximum');
$table->integer('minimum');
$table->integer('price');


+ 1
- 1
database/migrations/2021_05_19_185302_create_orders_table.php View File

@@ -24,7 +24,7 @@ class CreateOrdersTable extends Migration
$table->string('message')->nullable();
$table->bigInteger('remaining')->default(0);
$table->enum('status', ['processing', 'pending', 'canceled',
'refunded', 'completed', 'error']);
'refunded', 'partial', 'completed', 'error']);
$table->string('url');
});
}


+ 4
- 2
database/migrations/2021_06_23_145817_create_suppliers_table.php View File

@@ -19,11 +19,13 @@ class CreateSuppliersTable extends Migration
$table->foreignId('service_id')->constrained();
$table->string('supplier')->nullable();
$table->string('supplier_name')->nullable();
$table->string('supplier_link')->nullable();
$table->integer('supplier_id')->nullable();
$table->integer('supplier_id');
$table->integer('alternate_id')->nullable();
$table->integer('min');
$table->integer('max');
$table->integer('cost');
$table->integer('remaining')->nullable();
$table->boolean('available')->default(true);
$table->text('description')->default('');
});
}


+ 3
- 3
database/migrations/2021_06_24_135121_create_referrals_table.php View File

@@ -13,12 +13,12 @@ class CreateReferralsTable extends Migration
*/
public function up()
{
Schema::create('referrals', function (Blueprint $table) {
Schema::create('user_referrals', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('name');
$table->string('email');
$table->integer('rate')->default(25); //Percentage
$table->integer('rate')->default(10); //Percentage
$table->integer('limit')->default(20000); //Total limit in cents
$table->unsignedInteger('balance')->default(0);
$table->unsignedInteger('total')->default(0);
@@ -33,6 +33,6 @@ class CreateReferralsTable extends Migration
*/
public function down()
{
Schema::dropIfExists('referals');
Schema::dropIfExists('user_referrals');
}
}

+ 1
- 1
resources/views/home.blade.php View File

@@ -198,7 +198,7 @@

<div class="collapsible"><button>How can I pay?</button>
<div class="content"><p>
We accept Bitcoin, Litecoin, and other cryptocurrencies, as well as USD
We accept Debit/Credit or your choice of crytocurrency
through our Payeer and Perfect Money payment providers.
</p></div></div>



Loading…
Cancel
Save