Bladeren bron

Fixed filter bug

jquino 5 jaren geleden
bovenliggende
commit
64c7faaef0

+ 2
- 0
app/Http/Middleware/SetDept.php Bestand weergeven

@@ -15,6 +15,7 @@ class SetDept
15 15
      */
16 16
     public function handle($request, Closure $next)
17 17
     {
18
+        // dump($request);
18 19
         if ($request->has('f')) {
19 20
             $data = $request->validate(['f' => 'regex:/[df]/']);
20 21
             $request->session()->put('filter', $data['f']);
@@ -34,6 +35,7 @@ class SetDept
34 35
             $default_dept_id = \App\Department::where('name', '=', 'BIOL')->first()->id;
35 36
             $request->session()->put('department', $default_dept_id);
36 37
         }
38
+        // dump($request->session());
37 39
         return $next($request);
38 40
     }
39 41
 }

+ 1
- 1
database/migrations/2019_07_07_183013_create_departments_table.php Bestand weergeven

@@ -15,8 +15,8 @@ class CreateDepartmentsTable extends Migration
15 15
     {
16 16
         Schema::create('departments', function (Blueprint $table) {
17 17
             $table->bigIncrements('id');
18
+            $table->string('code')->nullable();
18 19
             $table->string('name')->nullable();
19
-            $table->string('title')->nullable();
20 20
             $table->unsignedBigInteger('faculty_id');
21 21
 
22 22
             $table->foreign('faculty_id')->references('id')->on('faculties');

+ 1
- 1
resources/views/dashboard/register.blade.php Bestand weergeven

@@ -102,7 +102,7 @@
102 102
                                                     </div>
103 103
                                                     <div class="mdc-checkbox__ripple"></div>
104 104
                                                 </div>
105
-                                                <label for="checkbox-d-{{ $loop->index }}">{{ $department->title ?: $department->name }}</label>
105
+                                                <label for="checkbox-d-{{ $loop->index }}">{{ $department->name ?: $department->code }}</label>
106 106
                                             </div>
107 107
                                         </div>
108 108
                                     @endforeach

+ 8
- 4
resources/views/layouts/app.blade.php Bestand weergeven

@@ -44,21 +44,25 @@
44 44
                     </li>
45 45
                     <li class="nav-item dropdown">
46 46
                         @php
47
-                            $department = \App\Department::find(Request()->session()->get('department'));
47
+                            switch(Request()->session()->get('filter')) {
48
+                                case 'f': $division = App\Faculty::find(Request()->session()->get('faculty')); break;
49
+                                case 'd': $division = App\Department::find(Request()->session()->get('department')); break;
50
+                                default: break;
51
+                            }
48 52
                         @endphp
49 53
                         <a class="nav-link dropdown-toggle mdc-typography--body1" href="#" data-toggle="dropdown">
50
-                            {{ $department->title ?: $department->name ?? 'Departamento' }} <span class="caret"></span>
54
+                            {{ $division->name ?: $division->code ?? 'Departamento' }} <span class="caret"></span>
51 55
                         </a>
52 56
                         <ul class="dropdown-menu">
53 57
                             @foreach (App\Faculty::orderBy('name')->get() as $faculty)
54
-                                @if (!$faculty->departments->isEmpty())
58
+                                @if ($faculty->departments->isNotEmpty())
55 59
                                     <li class="dropdown-submenu">
56 60
                                         <a class="dropdown-item dropdown-toggle mdc-typography--body1" href="#" data-toggle="dropdown">{{ $faculty->name }}</a>
57 61
                                         <ul class="dropdown-menu">
58 62
                                             @foreach ($faculty->departments as $dept)
59 63
                                                 <li class="mdc-typography--body2">
60 64
                                                     <a class="dropdown-item" href="{{ url()->current() }}?f=d&dept={{ $dept->id }}">
61
-                                                        {{ $dept->title ?: $dept->name }}
65
+                                                        {{ $dept->name ?: $dept->code }}
62 66
                                                     </a>
63 67
                                                 </li>
64 68
                                             @endforeach