diff --git a/app/Http/Controllers/ExercicioController.php b/app/Http/Controllers/ExercicioController.php index 4a06445..57977c7 100644 --- a/app/Http/Controllers/ExercicioController.php +++ b/app/Http/Controllers/ExercicioController.php @@ -27,11 +27,22 @@ class ExercicioController extends Controller /** * Display a listing of the resource. * - * @return \Illuminate\Http\Response */ public function index() { - return redirect()->action([TopicoController::class, 'index']); + $topicos = Topico::orderBy('order'); + $semTopico = Exercicio::whereDoesntHave('topico')->orderBy('name'); + /** @var \App\Models\User */ + $user = Auth::user(); + if (optional($user)->isAdmin()) { + $topicos = $topicos->with('exercicios'); + } else { + $topicos = $topicos->with('exerciciosPublished'); + $semTopico = $semTopico->published(); + } + + return View('exercicio.index')->with('topicos', $topicos->get()) + ->with('semTopico', $semTopico->get()); } /** diff --git a/app/Http/Controllers/TopicoController.php b/app/Http/Controllers/TopicoController.php index 465fba6..929b415 100644 --- a/app/Http/Controllers/TopicoController.php +++ b/app/Http/Controllers/TopicoController.php @@ -15,19 +15,7 @@ class TopicoController extends Controller */ public function index() { - $topicos = Topico::orderBy('order'); - $semTopico = Exercicio::whereDoesntHave('topico')->orderBy('name'); - /** @var \App\Models\User */ - $user = Auth::user(); - if (optional($user)->isAdmin()) { - $topicos = $topicos->with('exercicios'); - } else { - $topicos = $topicos->with('exerciciosPublished'); - $semTopico = $semTopico->published(); - } - - return View('topico.index')->with('topicos', $topicos->get()) - ->with('semTopico', $semTopico->get()); + return redirect()->action([ExercicioController::class, 'index']); } /** diff --git a/resources/views/exercicio/index.blade.php b/resources/views/exercicio/index.blade.php index 035d97f..b1f3323 100644 --- a/resources/views/exercicio/index.blade.php +++ b/resources/views/exercicio/index.blade.php @@ -1,6 +1,5 @@ @extends('layouts.base') @section('content') -

Exercícios

@@ -16,9 +15,9 @@ href="{{ URL::to('exercicio/create') }}">Cadastrar exercicio @endcan - @can ('order', App\Models\Topico::class) + @can ('sort', App\Models\Topico::class) Reordenar topicos + href="{{ URL::to('topico/sort') }}">Reordenar topicos @endcan @can ('create', App\Models\Topico::class) @@ -33,9 +32,8 @@ @if (Session::has('message'))
{{ Session::get('message') }}
@endif - - @include('exercicio.table', ['editButton' => true])
+ + @include('topico.table', ['editButton' => true]) - @endsection diff --git a/resources/views/topico/index.blade.php b/resources/views/topico/index.blade.php deleted file mode 100644 index b1f3323..0000000 --- a/resources/views/topico/index.blade.php +++ /dev/null @@ -1,39 +0,0 @@ -@extends('layouts.base') -@section('content') -
-

Exercícios

-
- -
- @can('bulk', App\Models\Exercicio::class) - Exportar todos - - @endcan - @can ('create', App\Models\Exercicio::class) - Cadastrar exercicio - - @endcan - @can ('sort', App\Models\Topico::class) - Reordenar topicos - - @endcan - @can ('create', App\Models\Topico::class) - Novo tópico - - @endcan -
- -
- - @if (Session::has('message')) -
{{ Session::get('message') }}
- @endif -
- - @include('topico.table', ['editButton' => true]) - -@endsection