feat : merancang database dengan menggunakan migrasi,model dan seeder
This commit is contained in:
parent
c9bdef47f8
commit
4f4ef2d99b
31
app/Models/Attachment.php
Normal file
31
app/Models/Attachment.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Attachment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'attachmentable_id',
|
||||
'attachmentable_type',
|
||||
'name',
|
||||
'extension',
|
||||
'size',
|
||||
];
|
||||
|
||||
public function getFormattedAttachmentAttribute(): string
|
||||
{
|
||||
return $this->created_at->format('Y-m-d').'/'.$this->name.'.'.$this->extension;
|
||||
}
|
||||
|
||||
public function attachmentable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
}
|
||||
36
app/Models/Attendance.php
Normal file
36
app/Models/Attendance.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Attendance extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'check_in',
|
||||
'check_out',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function attachments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
76
app/Models/Barbershop.php
Normal file
76
app/Models/Barbershop.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Barbershop extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'barbershop';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'contact_number',
|
||||
'landmark',
|
||||
'address',
|
||||
'opened',
|
||||
'closed',
|
||||
'cash',
|
||||
];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function customers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Customer::class);
|
||||
}
|
||||
|
||||
public function services(): HasMany
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
public function attendances(): HasMany
|
||||
{
|
||||
return $this->hasMany(Attendance::class);
|
||||
}
|
||||
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function inventory(): HasMany
|
||||
{
|
||||
return $this->hasMany(Inventory::class);
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
public function payrolls(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payroll::class);
|
||||
}
|
||||
|
||||
public function cash(): HasMany
|
||||
{
|
||||
return $this->hasMany(Cash::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
28
app/Models/Biography.php
Normal file
28
app/Models/Biography.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Biography extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'full_name',
|
||||
'pob',
|
||||
'dob',
|
||||
'contact_number',
|
||||
'address',
|
||||
'gender',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
38
app/Models/Cash.php
Normal file
38
app/Models/Cash.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Cash extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'cash';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'name',
|
||||
'amount',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
30
app/Models/Customer.php
Normal file
30
app/Models/Customer.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Customer extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'name',
|
||||
'contact_number',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
}
|
||||
36
app/Models/Expense.php
Normal file
36
app/Models/Expense.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Expense extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'name',
|
||||
'amount',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
39
app/Models/Inventory.php
Normal file
39
app/Models/Inventory.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Inventory extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'inventory';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'name',
|
||||
'quantity',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
45
app/Models/Payroll.php
Normal file
45
app/Models/Payroll.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Payroll extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'employee_id',
|
||||
'barbershop_id',
|
||||
'amount',
|
||||
'incentive',
|
||||
'cut',
|
||||
'total',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function employee(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'employee_id');
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
20
app/Models/Role.php
Normal file
20
app/Models/Role.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function users(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
||||
31
app/Models/Service.php
Normal file
31
app/Models/Service.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'name',
|
||||
'price',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
}
|
||||
25
app/Models/Setting.php
Normal file
25
app/Models/Setting.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'contact_number',
|
||||
'description',
|
||||
];
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
50
app/Models/Transaction.php
Normal file
50
app/Models/Transaction.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'barbershop_id',
|
||||
'customer_id',
|
||||
'service_id',
|
||||
'price',
|
||||
'discount',
|
||||
'total',
|
||||
'payment_method',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Service::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
@ -4,45 +4,86 @@
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable, SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'role_id',
|
||||
'barbershop_id',
|
||||
'username',
|
||||
'email',
|
||||
'password',
|
||||
'base_salary',
|
||||
'sop',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
public function role(): BelongsTo
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
return $this->belongsTo(Role::class);
|
||||
}
|
||||
|
||||
public function barbershop(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Barbershop::class);
|
||||
}
|
||||
|
||||
public function biography(): HasOne
|
||||
{
|
||||
return $this->hasOne(Biography::class);
|
||||
}
|
||||
|
||||
public function customers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Customer::class);
|
||||
}
|
||||
|
||||
public function services(): HasMany
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
}
|
||||
|
||||
public function attendances(): HasMany
|
||||
{
|
||||
return $this->hasMany(Attendance::class);
|
||||
}
|
||||
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function inventory(): HasMany
|
||||
{
|
||||
return $this->hasMany(Inventory::class);
|
||||
}
|
||||
|
||||
public function transactions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
public function payrolls(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payroll::class);
|
||||
}
|
||||
|
||||
public function cash(): HasMany
|
||||
{
|
||||
return $this->hasMany(Cash::class);
|
||||
}
|
||||
|
||||
public function attachment(): MorphOne
|
||||
{
|
||||
return $this->morphOne(Attachment::class, 'attachmentable');
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,14 +11,38 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 20);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('barbershop', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 50);
|
||||
$table->string('contact_number', 15);
|
||||
$table->string('landmark', 30);
|
||||
$table->text('address');
|
||||
$table->date('opened');
|
||||
$table->date('closed')->nullable();
|
||||
$table->decimal('cash', 10, 2)->default(0.00);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->string('username', 15)->unique();
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->string('password', 60);
|
||||
$table->decimal('base_salary', 10, 2)->default(0.00);
|
||||
$table->text('sop')->nullable();
|
||||
$table->enum('is_active', ['1', '0'])->default('1');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('biographies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('full_name');
|
||||
$table->string('pob', 75);
|
||||
$table->dateTime('dob');
|
||||
$table->string('contact_number', 15);
|
||||
$table->text('address');
|
||||
$table->enum('gender', ['1', '2'])->comment('1:Laki-Laki 2:Perempuan');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('biographies');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('customers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->string('name', 30);
|
||||
$table->string('contact_number', 15);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('customers');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('services', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->string('name', 100);
|
||||
$table->decimal('price', 8, 2);
|
||||
$table->text('description');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('services');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('expenses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->decimal('amount', 10, 2);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('expenses');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('payrolls', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('employee_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->decimal('amount', 10, 2)->comment('Base salary');
|
||||
$table->decimal('incentive', 10, 2);
|
||||
$table->decimal('cut', 10, 2);
|
||||
$table->decimal('total', 10, 2);
|
||||
$table->text('description');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('payrolls');
|
||||
}
|
||||
};
|
||||
32
database/migrations/2024_11_18_191551_create_cash_table.php
Normal file
32
database/migrations/2024_11_18_191551_create_cash_table.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cash', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->text('name');
|
||||
$table->decimal('amount', 10, 2);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cashes');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('attendances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->time('check_in');
|
||||
$table->time('check_out')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attendances');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->foreignId('customer_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('service_id')->constrained()->cascadeOnDelete();
|
||||
$table->decimal('price', 8, 2);
|
||||
$table->decimal('discount', 8, 2)->default(0);
|
||||
$table->decimal('total', 9, 2);
|
||||
$table->enum('payment_method', ['1', '2', '3'])->comment('1:Cash 2:Qris 3:Other');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('transactions');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('inventory', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('barbershop_id')->constrained('barbershop')->cascadeOnDelete();
|
||||
$table->string('name', 100);
|
||||
$table->integer('quantity');
|
||||
$table->text('description');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('inventories');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name', 30);
|
||||
$table->string('email');
|
||||
$table->string('contact_number', 15);
|
||||
$table->text('description');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->nullableMorphs('attachmentable');
|
||||
$table->string('name', 50);
|
||||
$table->string('extension', 10);
|
||||
$table->string('size', 10);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attachments');
|
||||
}
|
||||
};
|
||||
23
database/seeders/BarbershopSeeder.php
Normal file
23
database/seeders/BarbershopSeeder.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Barbershop;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class BarbershopSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Barbershop::create([
|
||||
'name' => 'XYZ Barbershop',
|
||||
'contact_number' => '08123456789',
|
||||
'landmark' => 'Depan J.co',
|
||||
'address' => 'Jl.Babaru Nagri',
|
||||
'opened' => '2023-01-01',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@ -13,11 +12,11 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
$this->call([
|
||||
RoleSeeder::class,
|
||||
BarbershopSeeder::class,
|
||||
UserSeeder::class,
|
||||
SettingSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
29
database/seeders/RoleSeeder.php
Normal file
29
database/seeders/RoleSeeder.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Role;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RoleSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$roles = [
|
||||
'Owner',
|
||||
'Direktur',
|
||||
'Admin',
|
||||
'Kasir',
|
||||
'Barber',
|
||||
];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
Role::create([
|
||||
'name' => $role,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
database/seeders/SettingSeeder.php
Normal file
22
database/seeders/SettingSeeder.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'XYZ Barbershop',
|
||||
'email' => 'barbershop@example.com',
|
||||
'contact_number' => '08123456789',
|
||||
'description' => 'Selamat datang di XYZ Barbershop, tempat di mana seni mencukur rambut bertemu dengan kenyamanan dan layanan berkualitas tinggi. Kami menghadirkan pengalaman potong rambut terbaik untuk pria yang ingin tampil percaya diri dan penuh gaya.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
70
database/seeders/UserSeeder.php
Normal file
70
database/seeders/UserSeeder.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Attachment;
|
||||
use App\Models\Biography;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::transaction(function () {
|
||||
// Create a new user
|
||||
$newUser = User::create([
|
||||
'role_id' => 1,
|
||||
'barbershop_id' => 1,
|
||||
'username' => 'yoga',
|
||||
'email' => 'yoga@developer.com',
|
||||
'password' => Hash::make(env('PASSWORD_DEFAULT_USER')),
|
||||
]);
|
||||
|
||||
// Create biography for the user
|
||||
Biography::create([
|
||||
'user_id' => $newUser->id,
|
||||
'full_name' => 'Yoga Pangestu',
|
||||
'pob' => 'Subang',
|
||||
'dob' => '2000-01-01',
|
||||
'contact_number' => '082121495806',
|
||||
'address' => 'Jl.Babaru Nagri',
|
||||
'gender' => 1,
|
||||
]);
|
||||
|
||||
// Path to the image file
|
||||
$imagePath = public_path('assets/admin/images/avatar/speed.jpeg');
|
||||
|
||||
// Check if the file exists
|
||||
if (file_exists($imagePath)) {
|
||||
// Create a Symfony file instance
|
||||
$file = new \Symfony\Component\HttpFoundation\File\File($imagePath);
|
||||
|
||||
// Generate a unique file name
|
||||
$fileName = Str::uuid().'.'.$file->getExtension();
|
||||
|
||||
// Create an attachment record
|
||||
Attachment::create([
|
||||
'attachmentable_id' => $newUser->id,
|
||||
'attachmentable_type' => User::class,
|
||||
'name' => $fileName,
|
||||
'extension' => $file->getExtension(),
|
||||
'size' => $file->getSize(),
|
||||
]);
|
||||
|
||||
// Define the storage path for avatars
|
||||
$path = 'avatars/'.now()->format('Y-m-d');
|
||||
|
||||
// Store the file in the defined path using Storage facade
|
||||
Storage::disk('public')->putFileAs($path, $file, $fileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user