-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Creating achievement module on monitoring page (WIP)
- Loading branch information
Showing
30 changed files
with
647 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources\DataTables; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
/** | ||
* @property \App\Models\Achievement $resource | ||
*/ | ||
class AchievementResource extends JsonResource | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function toArray($request) | ||
{ | ||
$elements = []; | ||
|
||
if ($request->user()->can('view', $this->resource)) { | ||
$elements[] = view('components.datatables.link-show', [ | ||
'url' => route('monitoring.achievement.show', $this->resource), | ||
])->render(); | ||
} | ||
|
||
if ($request->user()->can('update', $this->resource)) { | ||
$elements[] = view('components.datatables.link-edit', [ | ||
'url' => route('monitoring.achievement.edit', $this->resource), | ||
])->render(); | ||
} | ||
|
||
if ($request->user()->can('delete', $this->resource)) { | ||
$elements[] = view('components.datatables.link-destroy', [ | ||
'url' => route('monitoring.achievement.destroy', $this->resource), | ||
])->render(); | ||
} | ||
|
||
return [ | ||
'checkbox' => view('components.datatables.checkbox', [ | ||
'value' => $this->resource->getKey(), | ||
])->render(), | ||
'branch_name' => view('components.datatables.link', [ | ||
'url' => route('master.branch.show', $this->resource->target->branch), | ||
'name' => $this->resource->target->branch->name, | ||
])->render(), | ||
'event_name' => view('components.datatables.link', [ | ||
'url' => $this->resource->event ? route('monitoring.event.show', $this->resource->event->branch) : '#', | ||
'name' => $this->resource->event ? $this->resource->event->name : '-', | ||
])->render(), | ||
'achieved_date' => $this->resource->achieved_date_iso_format, | ||
'achieved_by' => view('components.datatables.link', [ | ||
'url' => $this->resource->achievedBy ? route('master.user.show', $this->resource->achievedBy) : '#', | ||
'name' => $this->resource->achievedBy ? $this->resource->achievedBy->name : '-', | ||
])->render(), | ||
'amount' => $this->resource->getRawAttribute('amount'), | ||
'action' => view('components.datatables.button-group', compact('elements'))->render(), | ||
]; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Infrastructure\Models\Relation; | ||
|
||
use App\Models\Branch; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
interface BelongsToBranch | ||
{ | ||
/** | ||
* Define an inverse one-to-many relationship with \App\Models\Branch. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function branch(): BelongsTo; | ||
|
||
/** | ||
* Return \App\Models\Branch model relation value. | ||
* | ||
* @return \App\Models\Branch|null | ||
*/ | ||
public function getBranchRelationValue(); | ||
|
||
/** | ||
* Set \App\Models\Branch model relation value. | ||
* | ||
* @param \App\Models\Branch $branch | ||
* @return $this | ||
*/ | ||
public function setBranchRelationValue(Branch $branch); | ||
} |
31 changes: 31 additions & 0 deletions
31
app/Infrastructure/Models/Relation/HasManyAchievements.php
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,31 @@ | ||
<?php | ||
|
||
namespace App\Infrastructure\Models\Relation; | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
|
||
interface HasManyAchievements | ||
{ | ||
/** | ||
* Define a one-to-many relationship with \App\Models\Achievement. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | ||
*/ | ||
public function achievements(): HasMany; | ||
|
||
/** | ||
* Return collection of \App\Models\Achievement model relation value. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Collection<\App\Models\Achievement> | ||
*/ | ||
public function getAchievementsRelationValue(): Collection; | ||
|
||
/** | ||
* Set collection of \App\Models\Achievement model relation value. | ||
* | ||
* @param \Illuminate\Database\Eloquent\Collection<\App\Models\Achievement> $achievements | ||
* @return $this | ||
*/ | ||
public function setAchievementsRelationValue(Collection $achievements); | ||
} |
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
Oops, something went wrong.