-
Notifications
You must be signed in to change notification settings - Fork 1
Add backend for quests #145
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f759c44
Fix random issues
ttoino 805c614
Fix triggers in migrations
ttoino ed44f3f
Improve user factories
ttoino dc6117c
Improve seeder, seed enrollments
ttoino f5baf7c
Fix mistake in user factories
ttoino 3833217
Fix seeder
ttoino e80db1e
Add completeness effect to slots
ttoino 498321c
Fix requirements in quest crud
ttoino e845446
Fix typescript errors
ttoino 688d755
Fix some errors in the events
ttoino 2c6249a
Add endpoint to give a user a quest
ttoino 96e6512
Fix a typo
ttoino c2e322e
Fix linting issue
ttoino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Models\Participant; | ||
| use App\Models\Quest; | ||
| use Illuminate\Http\Request; | ||
| use Illuminate\Support\Facades\Gate; | ||
|
|
||
| class QuestController extends Controller | ||
| { | ||
| public function give(Request $request, Quest $quest) | ||
| { | ||
| $request->validate([ | ||
| 'quest_code' => 'required|exists:participants,quest_code', | ||
| ]); | ||
|
|
||
| $edition = $request->input('edition'); | ||
| $participant = Participant::firstWhere('quest_code', $request->get('quest_code')); | ||
| $enrollment = $participant->enrollments()->where('edition_id', $edition?->id)->first(); | ||
|
|
||
| Gate::authorize('give', [$quest, $enrollment]); | ||
|
|
||
| $enrollment->quests()->attach($quest); | ||
|
|
||
| return redirect()->back()->banner('Quest atribuída com sucesso!'); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,26 @@ | ||
| <?php | ||
|
|
||
| namespace Database\Factories; | ||
|
|
||
| use App\Models\Edition; | ||
| use App\Models\Participant; | ||
| use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
|
||
| /** | ||
| * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Enrollment> | ||
| */ | ||
| class EnrollmentFactory extends Factory | ||
| { | ||
| /** | ||
| * Define the model's default state. | ||
| * | ||
| * @return array<string, mixed> | ||
| */ | ||
| public function definition(): array | ||
| { | ||
| return [ | ||
| 'edition_id' => Edition::factory(), | ||
| 'participant_id' => Participant::factory(), | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.