diff --git a/app/Http/Controllers/PositionsController.php b/app/Http/Controllers/PositionsController.php index 8984a55b..73aa93a3 100644 --- a/app/Http/Controllers/PositionsController.php +++ b/app/Http/Controllers/PositionsController.php @@ -17,7 +17,7 @@ class PositionsController extends Controller */ public function jobs() { - $positions = Position::approved() + $positions = Position::approvedOrOwner() ->with(['author']) ->whereDate('created_at', '>=', now()->subMonths(2)) ->orderBy('id', 'desc') diff --git a/app/Models/Concerns/Approvable.php b/app/Models/Concerns/Approvable.php index be14a91a..8e8c0229 100644 --- a/app/Models/Concerns/Approvable.php +++ b/app/Models/Concerns/Approvable.php @@ -16,8 +16,21 @@ trait Approvable */ public function scopeApproved(Builder $query, bool $approved = true): Builder { - return $query->where('approved', $approved) - ->orWhere('user_id', auth()->id()); + return $query->where('approved', $approved); + } + + + /** + * Scope a query to only include approved or owner items. + * + * @param Builder $query + * @param bool $approved + * + * @return Builder + */ + public function scopeApprovedOrOwner(Builder $query, bool $approved = true): Builder + { + return $query->approved($approved)->orWhere('user_id', auth()->id()); } /**