api code global jain

This commit is contained in:
Abhishek Mali
2025-11-05 10:37:10 +05:30
commit 52fe7e2bec
2834 changed files with 1784903 additions and 0 deletions

56
app/Rules/DeleteVihar.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
namespace App\Rules;
use App\Models\Vihar;
use Carbon\Carbon;
use Illuminate\Contracts\Validation\Rule;
class DeleteVihar implements Rule
{
public $sant_id;
public $start_date;
public $start_time;
public $vihar_id;
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct($vihar = null)
{
$this->sant_id = $vihar['sant_id'];
$this->start_date = $vihar['start_date'];
$this->start_time = $vihar['start_time'];
$this->vihar_id = $vihar['id'];
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
$numberOfVihar = Vihar::where('id', $this->vihar_id)->where('start_time', '<=', Carbon::now()->format('H:i'))->count();
if ($numberOfVihar > 0) {
return false;
} else {
return true;
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Vihar is already started so you can`t delete it.';
}
}