Skip to content

Commit

Permalink
Merge pull request #75 from ranggaadithia/history
Browse files Browse the repository at this point in the history
History
  • Loading branch information
ranggaadithia authored Dec 22, 2023
2 parents 0de2b2e + 96cd126 commit 1e9385d
Show file tree
Hide file tree
Showing 11 changed files with 713 additions and 563 deletions.
9 changes: 6 additions & 3 deletions app/Http/Controllers/LabController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace App\Http\Controllers;

use Mpdf\Tag\Time;
use App\Models\Lab;
use App\Utilities\TimeMappings;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Utilities\TimeMappings;
use Illuminate\Support\Facades\Route;
use Illuminate\Database\QueryException;
use Mpdf\Tag\Time;

class LabController extends Controller
{
Expand Down Expand Up @@ -52,7 +53,9 @@ public function store(Request $request)
*/
public function show(Lab $lab)
{
return view('home.lab', compact('lab'));
$labs = Lab::all();
$timeMappings = TimeMappings::$timeMappings;
return view('home.lab', compact('lab', 'labs', 'timeMappings'));
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/Livewire/LabSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public function previousWeek()
$this->mount();
}

#[On('success-booking-lab')]
public function updateSchedule($schedule)
{
}

public function mount()
{
$this->startDate = Carbon::now()->startOfWeek()->addWeeks($this->currentWeek - 1);
Expand Down
12 changes: 12 additions & 0 deletions app/Livewire/ModalBooking.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Carbon\Carbon;

use App\Models\Lab;
use Livewire\Component;
use App\Models\LabsBooking;
use App\Models\ClassSchedule;
Expand All @@ -21,6 +22,16 @@ public function mount($labs, $user, $timeMappings)
$this->labs = $labs;
$this->user = $user;
$this->timeMappings = $timeMappings;

if (request()->routeIs('lab.view')) {
$currentSlug = request()->segment(2);

// Find the lab with the matching slug
$lab = Lab::where('slug', $currentSlug)->first();

// Set lab_id to the ID of the lab with the matching slug
$this->lab_id = optional($lab)->id;
}
}

public $lab_id;
Expand Down Expand Up @@ -81,6 +92,7 @@ public function bookingLab()

$this->dispatch('close-modal');
$this->dispatch('success-booking', schedule: $data['user_id']);
$this->dispatch('success-booking-lab', schedule: $data['lab_id']);
$this->resetForm();
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"livewire/livewire": "^3.0",
"livewire/livewire": "^3.3",
"maatwebsite/excel": "^3.1",
"psr/simple-cache": "^2.0"
},
Expand Down
Loading

0 comments on commit 1e9385d

Please sign in to comment.