buang limit sehari
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Http\Controllers;
|
|||||||
use App\Models\SesiTaklimat;
|
use App\Models\SesiTaklimat;
|
||||||
use App\Models\Sppm\Dun;
|
use App\Models\Sppm\Dun;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
|
|
||||||
class SesiTaklimatController extends Controller
|
class SesiTaklimatController extends Controller
|
||||||
{
|
{
|
||||||
@@ -43,18 +42,12 @@ class SesiTaklimatController extends Controller
|
|||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'dun_id' => [
|
// Beberapa sesi dibenarkan dalam satu hari bagi setiap DUN
|
||||||
'required',
|
'dun_id' => ['required', 'integer'],
|
||||||
'integer',
|
|
||||||
// Hanya 1 sesi dalam 1 hari untuk setiap dun
|
|
||||||
Rule::unique('sesi_taklimat', 'dun_id')->where('tarikh', $request->input('tarikh')),
|
|
||||||
],
|
|
||||||
'tarikh' => ['required', 'date'],
|
'tarikh' => ['required', 'date'],
|
||||||
'nama' => ['required', 'string', 'max:255'],
|
'nama' => ['required', 'string', 'max:255'],
|
||||||
'lokasi' => ['required', 'string', 'max:255'],
|
'lokasi' => ['required', 'string', 'max:255'],
|
||||||
'masa' => ['nullable', 'string', 'max:100'],
|
'masa' => ['nullable', 'string', 'max:100'],
|
||||||
], [
|
|
||||||
'dun_id.unique' => 'Sesi taklimat untuk DUN ini sudah wujud pada tarikh tersebut. Hanya 1 sesi dibenarkan sehari bagi setiap DUN.',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($user->isPengurus() && (int) $data['dun_id'] !== (int) $user->dun_id) {
|
if ($user->isPengurus() && (int) $data['dun_id'] !== (int) $user->dun_id) {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('sesi_taklimat', function (Blueprint $table) {
|
||||||
|
// Benarkan beberapa sesi dalam satu hari untuk setiap DUN
|
||||||
|
$table->dropUnique(['dun_id', 'tarikh']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('sesi_taklimat', function (Blueprint $table) {
|
||||||
|
$table->unique(['dun_id', 'tarikh']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user