123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Models;
- use App\Http\Requests\IndexHelper;
- use App\Models\Enums\DisplayIndexObjectType;
- use App\Models\Scopes\CompanyScope;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\SoftDeletes;
- class ApprovalFlow extends Model
- {
- use HasFactory, SoftDeletes;
- protected $fillable = [
- 'name', 'object_type', 'object_id', 'nodes', 'nodes_config', 'created_by',
- ];
- protected $casts = [
- 'nodes' => 'array',
- ];
- protected static function booted(): void
- {
- static::addGlobalScope(new CompanyScope);
- static::creating(function (ApprovalFlow $approvalFlow){
- $type =DisplayIndexObjectType::APPROVALFLOW;
- $displayIndex = IndexHelper::getObjectMaxIndex($type);
- $approvalFlow->display_id =$displayIndex;
- });
- }
- public function createdBy()
- {
- return $this->belongsTo(User::class, "created_by");
- }
- }
|