mastercut/app/Models/Payroll.php

48 lines
1.0 KiB
PHP

<?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',
'shaving_result',
'cut',
'percentage_shaving',
'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');
}
}