Initial Commit

This commit is contained in:
dev 2021-07-15 23:35:54 -07:00
commit cc2af611e1
148 changed files with 54234 additions and 0 deletions

1
database/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.sqlite*

View file

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\Address;
use Illuminate\Database\Eloquent\Factories\Factory;
class AddressFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Address::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
//
];
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use App\Models\Meme;
use App\Models\User;
use App\Models\Address;
use Illuminate\Database\Eloquent\Factories\Factory;
class MemeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Meme::class;
private static $address_id = 1;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'user_id' => User::all()->random()->id,
'address_id' => self::$address_id++,
'title' => $this->faker->sentence($nbWords = 3, $variableNbWords = true),
'image' => 'blah.png',
];
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Models\Tip;
use App\Models\Meme;
use Illuminate\Database\Eloquent\Factories\Factory;
class TipFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Tip::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'meme_id' => Meme::all()->random()->id,
'amount' => $this->faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = 1),
'tx' => $this->faker->bothify('??#?#?###??#???#?#?###??#???#?#?###??#???#?#?###??#??##??#?#?###??#???#?#?###??#???#?#?###??#??'),
];
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->name(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'address' => $this->faker->bothify('??#?#?###??#???#?#?###??#???#?#?###??#???#?#?###??#??##??#?#?###??#???#?#?###??#???#?#?###??#??'),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function unverified()
{
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View file

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->string('address', 95);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

View file

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAddressesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->id();
$table->string('address', 95)->unique();
$table->integer('address_index');
$table->string('label');
$table->boolean('used');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('addresses');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMemesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('memes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->foreignId('address_id')->constrained();
$table->string('title');
$table->string('caption')->nullable();
$table->string('image')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('memes');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTipsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tips', function (Blueprint $table) {
$table->id();
$table->foreignId('address_id')->constrained();
$table->bigInteger('amount');
$table->string('txid')->unique();
$table->bigInteger('height');
$table->boolean('is_sent')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tips');
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use MoneroIntegrations\MoneroPhp\walletRPC;
class AddressSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
try {
$walletRPC = new walletRPC('127.0.0.1', config('app.xmr_network_port')); // Change to match your wallet (monero-wallet-rpc) IP address and port; 18083 is the customary port for mainnet, 28083 for testnet, 38083 for stagenet
$create_wallet = $walletRPC->create_wallet(config('app.xmr_wallet_name'), ''); // Creates a new wallet named memes with no passphrase. Comment this line and edit the next line to use your own wallet
} catch (\Exception $e) {
dump($e->getMessage());
}
try {
$open_wallet = $walletRPC->open_wallet(config('app.xmr_wallet_name'), '');
for ($i=0; $i < 100; $i++) {
$create_address = $walletRPC->create_address(0, 'Example');
}
$get_address = $walletRPC->get_address();
\DB::table('addresses')->insertOrIgnore($get_address['addresses']);
$walletRPC->close_wallet();
} catch (\Exception $e) {
dump($e->getMessage());
}
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
\App\Models\User::factory(10)->create();
\App\Models\Meme::factory(80)->create();
// \App\Models\Tip::factory(500)->create();
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class MemeSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class TipSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}