Skip to content

Commit

Permalink
fix issues in BlockController #76
Browse files Browse the repository at this point in the history
  • Loading branch information
Davud Evren authored and carlobeltrame committed Nov 8, 2023
1 parent 182fe9b commit 6352e7a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/Http/Controllers/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
use Exception;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
use function Psy\debug;

class BlockController extends Controller {
/**
Expand Down Expand Up @@ -98,7 +96,7 @@ public function import(BlockImportRequest $request, Course $course) {
}

/**
* Display a listing of the resource.
* Display a form to generate blocks.
*
* @return View
*/
Expand All @@ -108,23 +106,21 @@ public function generate(): View
}

/**
* Store an uploaded list of blocks in storage.
* Store an generated list of blocks in storage.
*
* @param BlockGenerateRequest $request
* @param Course $course
* @return RedirectResponse
* @throws ValidationException if parsing the uploaded file fails
*/
public function generateStore(BlockGenerateRequest $request, Course $course): RedirectResponse
{
$generated = DB::transaction(function () use ($request, $course,) {
$generated = DB::transaction(function () use ($request, $course) {
$request->validated();
$startDate = $request->date('blocks_startdate');
$endDate = $request->date('blocks_enddate');
$days = $startDate->diffInDays($endDate);
if($days > 370) {
$request->session()->flash('alert-danger', __('t.views.admin.block_generate.error_too_many_blocks'));
throw ValidationException::withMessages([trans('t.views.admin.block_generate.error_too_many_blocks')]);
throw ValidationException::withMessages(['blocks_enddate' => trans('t.views.admin.block_generate.error_too_many_blocks')]);
}
$result = collect([]);
$data = $request->validated();
Expand Down

0 comments on commit 6352e7a

Please sign in to comment.