Home screen improvements, testing for role, work on user/account models

This commit is contained in:
Deon George
2022-04-21 14:41:26 +10:00
parent 40d12b906b
commit 796c72dd09
18 changed files with 528 additions and 241 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Rtm>
*/
class RtmFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'id' => $this->faker->numberBetween(2048,65535),
//* 'site_id', // Needs to be passed in
//* 'account_id', // Needs to be passed in
// 'name',
//* 'parent_id', // Needs to be passed in
];
}
}

View File

@@ -1,23 +1,49 @@
<?php
use Faker\Generator as Faker;
namespace Database\Factories;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
use App\Models\Country;
use App\Models\Language;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
$factory->define(App\Models\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
// Create Dependencies - should be loaded by seeding.
$co = Country::findOrFail(61);
$lo = Language::findOrFail(1);
return [
'id' => $this->faker->numberBetween(2048,65535),
// 'created_at'
// 'updated_at'
//* 'site_id', // Needs to be passed in
'email' => $this->faker->unique()->safeEmail,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => Str::random(10),
'active' => 1,
// 'title'
'firstname' => $this->faker->name,
'lastname' => $this->faker->name,
'country_id' => $co->id,
// 'address1'
// 'address2'
// 'city'
// 'state'
// 'postcode'
'emailable' => true,
// 'parent_id''
'language_id' => $lo->id,
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->datetime('created_at')->nullable()->after('id');
$table->datetime('updated_at')->nullable()->after('created_at');
$table->date('expire_at')->nullable()->after('updated_at');
});
// Convert our dates
foreach (\App\Models\Account::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->cursor() as $o) {
if ($o->date_orig)
$o->created_at = \Carbon\Carbon::createFromTimestamp($o->date_orig);
if ($o->date_last)
$o->updated_at = \Carbon\Carbon::createFromTimestamp($o->date_last);
if ($o->date_expire)
$o->expire_at = \Carbon\Carbon::createFromTimestamp($o->date_expire);
$o->save();
}
Schema::table('accounts', function (Blueprint $table) {
$table->dropColumn(['date_orig','date_last','date_expire']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
abort(500,'Cant go back');
}
};