Assessment Related | System Related | None Implement |
---|---|---|
Users_Table | Cache_Table | Personal_Access_Token_table |
Merchants_Table | Jobs_Table | |
Notes_Table | … |
Users
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('password');
// $table->timestamp('email_verified_at')->nullable(); // email verify
// $table->boolean('two_factor_enabled')->default(false); // 2FA Enabled
$table->rememberToken();
$table->timestamps();
});
Merchants
Schema::create('merchants', function (Blueprint $table) {
$table->id();
$table->string('uid')->unique();
$table->string('name');
$table->string('phone')->nullable();
$table->string('email')->unique()->nullable();
$table->string('category')->nullable(); // 'restaurant', 'auto', 'pharmacy' etc.
$table->timestamps();
});
Notes
Schema::create('notes', function (Blueprint $table) {
$table->foreignId('merchant_id')->constrained(); // note belongs to
$table->foreignId('created_by')->constrained('users'); // user who wrote it
$table->foreignId('assigned_to')->nullable()->constrained('users'); // optional assignee
$table->id();
$table->string('uid')->unique();
$table->string('title'); // note title
$table->text('body'); // note contents
$table->string('type')->default('info'); // info, task, alert, etc.
$table->string('status')->default('open'); // open, closed, in progress etc.
$table->timestamps();
});
User
// User can create many notes
public function notes()
{
return $this->hasMany(Note::class, 'created_by');
}
Merchant
// Merchant can has many notes - note_id
public function notes()
{
return $this->hasMany(Note::class);
}
Note
// Note belongs to one merchant
public function merchant()
{
return $this->belongsTo(Merchant::class);
}
// Note belongs to one user (creator)
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
// Note belongs to one user (assignee) - NOT IMPLEMENTED
public function assignee()
{
return $this->belongsTo(User::class, 'assigned_to');
}
User