-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from sourcetoad/switch-to-owner-concept
Switch to Owner Concept
- Loading branch information
Showing
18 changed files
with
693 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sourcetoad\Logger\Contracts; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
interface Trackable | ||
{ | ||
public function trackableOwnerResolver(): ?Model; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Sourcetoad\Logger\Helpers; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Sourcetoad\Logger\Contracts\Trackable; | ||
|
||
class AuditResolver | ||
{ | ||
public static function findUserId(?Model $model): ?int | ||
public static function findOwner(?Trackable $model): ?Model | ||
{ | ||
if (empty($model)) { | ||
return null; | ||
} | ||
|
||
$id = $model->trackableUserResolver(); | ||
$owner = $model->trackableOwnerResolver(); | ||
|
||
if (empty($id)) { | ||
if (empty($owner)) { | ||
return null; | ||
} | ||
|
||
return $id; | ||
return $owner; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.