Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
koykoy027 committed May 22, 2024
1 parent 2a41c70 commit 50b35ec
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/User/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function update(UserUpdateRequest $request, $id)
$user->update(
array_merge(
$request->only(['email']),
$this->updatedBy()
$this->updated_by()
)
);

Expand Down
16 changes: 8 additions & 8 deletions app/Http/Resources/GlobalParameterResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public function toArray(Request $request): array
'description' => $this->description ?? null,
'is_active' => $this->is_active ?? null,
'created_by' => [
'id' => $this->createdBy->userProfile->id ?? null,
'firstname' => $this->createdBy->userProfile->firstname ?? null,
'middlename' => $this->createdBy->userProfile->middlename ?? null,
'lastname' => $this->createdBy->userProfile->lastname ?? null,
'id' => $this->created_by_user_profile->id ?? null,
'firstname' => $this->created_by_user_profile->firstname ?? null,
'middlename' => $this->created_by_user_profile->middlename ?? null,
'lastname' => $this->created_by_user_profile->lastname ?? null,
],

'updated_by' => [
'id' => $this->updatedBy->userProfile->id ?? null,
'firstname' => $this->updatedBy->userProfile->firstname ?? null,
'middlename' => $this->updatedBy->userProfile->middlename ?? null,
'lastname' => $this->updatedBy->userProfile->lastname ?? null,
'id' => $this->updated_by_user_profile->id ?? null,
'firstname' => $this->updated_by_user_profile->firstname ?? null,
'middlename' => $this->updated_by_user_profile->middlename ?? null,
'lastname' => $this->updated_by_user_profile->lastname ?? null,
],
];
}
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Resources/GlobalParameterTypeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public function toArray(Request $request): array
'description' => $this->description ?? null,
'is_active' => $this->is_active ?? null,
'created_by' => [
'id' => $this->createdBy->userProfile->id ?? null,
'firstname' => $this->createdBy->userProfile->firstname ?? null,
'middlename' => $this->createdBy->userProfile->middlename ?? null,
'lastname' => $this->createdBy->userProfile->lastname ?? null,
'id' => $this->created_by_user_profile->id ?? null,
'firstname' => $this->created_by_user_profile->firstname ?? null,
'middlename' => $this->created_by_user_profile->middlename ?? null,
'lastname' => $this->created_by_user_profile->lastname ?? null,
],
'updated_by' => [
'id' => $this->updatedBy->userProfile->id ?? null,
'firstname' => $this->updatedBy->userProfile->firstname ?? null,
'middlename' => $this->updatedBy->userProfile->middlename ?? null,
'lastname' => $this->updatedBy->userProfile->lastname ?? null,
'id' => $this->updated_by_user_profile->id ?? null,
'firstname' => $this->updated_by_user_profile->firstname ?? null,
'middlename' => $this->updated_by_user_profile->middlename ?? null,
'lastname' => $this->updated_by_user_profile->lastname ?? null,
],
];
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/GlobalParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public function globalParameterType(): BelongsTo
return $this->belongsTo(GlobalParameterType::class, 'type', 'id');
}

public function createdBy()
public function created_by_user_profile()
{
return $this->belongsTo(UserProfile::class, 'created_by', 'id');
}

public function updatedBy()
public function updated_by_user_profile()
{
return $this->belongsTo(UserProfile::class, 'updated_by', 'id');
}
Expand Down
9 changes: 4 additions & 5 deletions app/Models/GlobalParameterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class GlobalParameterType extends Model
{
Expand All @@ -18,13 +17,13 @@ public function globalParameters(): HasMany
return $this->hasMany(GlobalParameter::class, 'id');
}

public function createdBy()
public function created_by_user_profile()
{
return $this->belongsTo(User::class, 'created_by', 'id');
return $this->belongsTo(UserProfile::class, 'created_by', 'id');
}

public function updatedBy()
public function updated_by_user_profile()
{
return $this->belongsTo(User::class, 'updated_by', 'id');
return $this->belongsTo(UserProfile::class, 'updated_by', 'id');
}
}
4 changes: 2 additions & 2 deletions app/Traits/CreatedByAndUpdatedBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ private function createdByAndUpdatedBy()
];
}

private function createdBy()
private function created_by()
{
return ['created_by' => Auth::user()->id];
}

private function updatedBy()
private function updated_by()
{
return ['updated_by' => Auth::user()->id];
}
Expand Down

0 comments on commit 50b35ec

Please sign in to comment.