Skip to content

Use $dateFormat #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions src/Models/StoredWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,15 @@ final class StoredWorkflow extends Model
*/
protected $guarded = [];

protected $dateFormat = 'Y-m-d H:i:s.u';

/**
* @var array<string, class-string<\Workflow\States\WorkflowStatus>>
*/
protected $casts = [
'status' => WorkflowStatus::class,
];

public function getCreatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setCreatedAtAttribute(Carbon $value): void
{
$this->attributes['created_at'] = $value->format('Y-m-d H:i:s.u');
}

public function getUpdatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setUpdatedAtAttribute(Carbon $value): void
{
$this->attributes['updated_at'] = now()->format('Y-m-d H:i:s.u');
}

public function toWorkflow()
{
return WorkflowStub::fromStoredWorkflow($this);
Expand Down
10 changes: 1 addition & 9 deletions src/Models/StoredWorkflowException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ final class StoredWorkflowException extends Model
*/
protected $guarded = [];

public function getCreatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setCreatedAtAttribute(Carbon $value): void
{
$this->attributes['created_at'] = $value->format('Y-m-d H:i:s.u');
}
protected $dateFormat = 'Y-m-d H:i:s.u';

public function workflow(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
Expand Down
10 changes: 1 addition & 9 deletions src/Models/StoredWorkflowLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ final class StoredWorkflowLog extends Model
*/
protected $guarded = [];

public function getCreatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setCreatedAtAttribute(Carbon $value): void
{
$this->attributes['created_at'] = $value->format('Y-m-d H:i:s.u');
}
protected $dateFormat = 'Y-m-d H:i:s.u';

public function workflow(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
Expand Down
10 changes: 1 addition & 9 deletions src/Models/StoredWorkflowSignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ final class StoredWorkflowSignal extends Model
*/
protected $guarded = [];

public function getCreatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setCreatedAtAttribute(Carbon $value): void
{
$this->attributes['created_at'] = $value->format('Y-m-d H:i:s.u');
}
protected $dateFormat = 'Y-m-d H:i:s.u';

public function workflow(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
Expand Down
24 changes: 3 additions & 21 deletions src/Models/StoredWorkflowTimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,15 @@ final class StoredWorkflowTimer extends Model
*/
protected $guarded = [];

protected $dateFormat = 'Y-m-d H:i:s.u';

/**
* @var array<string, class-string<\datetime>>
*/
protected $casts = [
'stop_at' => 'datetime',
'stop_at' => 'datetime:Y-m-d H:i:s.u',
];

public function getCreatedAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setCreatedAtAttribute(Carbon $value): void
{
$this->attributes['created_at'] = $value->format('Y-m-d H:i:s.u');
}

public function getStopAtAttribute(string $value): Carbon
{
return Carbon::createFromFormat('Y-m-d H:i:s.u', $value);
}

public function setStopAtAttribute(Carbon $value): void
{
$this->attributes['stop_at'] = $value->format('Y-m-d H:i:s.u');
}

public function workflow(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(StoredWorkflow::class);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy