30 lines
767 B
PHP
30 lines
767 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Guest;
|
|
|
|
use App\Http\Controllers\HashidControllerBase;
|
|
use App\Models\SharedStudy;
|
|
|
|
class ViewSharedStudyController extends HashidControllerBase
|
|
{
|
|
public function show()
|
|
{
|
|
$this->decodeKeys();
|
|
$share = SharedStudy::findOrFail($this->key);
|
|
abort_if($share->hasExpired(), 404);
|
|
|
|
if ($share->isPasswordProtected()) {
|
|
return view('guest.shared-study.auth', compact('share'));
|
|
}
|
|
|
|
return view('guest.shared-study.show', compact('share'));
|
|
}
|
|
|
|
public function auth(SharedStudyPasswordRequest $request)
|
|
{
|
|
$this->decodeKeys();
|
|
$share = SharedStudy::findOrFail($this->key);
|
|
abort_if(! $share->attempt($request->password), 403);
|
|
}
|
|
}
|