-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hub-email-verification
- Loading branch information
Showing
25 changed files
with
305 additions
and
46 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
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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\LtiTool; | ||
use App\Models\LtiToolExtra; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
use function is_string; | ||
|
||
class AddLtiToolExtra extends Command | ||
{ | ||
protected $signature = <<<'EOF' | ||
edlib:add-lti-tool-extra | ||
{parent : ID or slug of the parent tool} | ||
{name : The name of the extra} | ||
{url : The launch URL for the extra} | ||
{--admin : The extra is for admins only} | ||
{--slug= : An optional slug for the extra} | ||
EOF; | ||
|
||
public function handle(): void | ||
{ | ||
$tool = LtiTool::where('id', $this->argument('parent')) | ||
->orWhere('slug', $this->argument('parent')) | ||
->firstOrFail(); | ||
|
||
DB::transaction(function () use ($tool) { | ||
$slug = $this->option('slug'); | ||
$extra = new LtiToolExtra(); | ||
$extra->name = $this->argument('name'); | ||
$extra->lti_launch_url = $this->argument('url'); | ||
$extra->admin = $this->option('admin'); | ||
if (is_string($slug)) { | ||
$extra->slug = $slug; | ||
} | ||
$extra->lti_tool_id = $tool->id; | ||
$extra->save(); | ||
}); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
sourcecode/hub/app/Http/Requests/AttachContextToContentsRequest.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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\Context; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
class AttachContextToContentsRequest extends FormRequest | ||
{ | ||
/** | ||
* @return array<mixed> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'context' => ['required', Rule::exists(Context::class, 'id')], | ||
]; | ||
} | ||
|
||
public function getContext(): Context | ||
{ | ||
return Context::where('id', $this->validated('context'))->firstOrFail(); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\Content; | ||
use App\Models\Context; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class AttachContextToContents implements ShouldQueue, ShouldBeUnique | ||
{ | ||
use Dispatchable; | ||
use Queueable; | ||
use SerializesModels; | ||
|
||
public function __construct(private readonly Context $context) {} | ||
|
||
public function handle(): void | ||
{ | ||
Content::lazy()->each(function (Content $content) { | ||
$content->contexts()->syncWithoutDetaching([$this->context]); | ||
}); | ||
} | ||
} |
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.