mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-19 04:13:58 +00:00
contract obligation complete and accept api
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Rules\User;
|
||||
|
||||
use Auth;
|
||||
use App\Models\Contract;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class ContractDoneCheck implements Rule
|
||||
{
|
||||
/**
|
||||
* Create a new rule instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
$value = is_array($value) ? $value : [$value];
|
||||
|
||||
$allow = true;
|
||||
foreach ($value as $key => $row) {
|
||||
if(!empty($row)) {
|
||||
$id = Hasher::decode('contracts', $row);
|
||||
$contract = Contract::
|
||||
where('id', $id)
|
||||
->first();
|
||||
|
||||
foreach ($contract->contract_obligation_list as $key => $row) {
|
||||
echo $row->status;
|
||||
if ($row->status != config('constants.contract_obligation.status.active')) {
|
||||
$allow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
if ($this->type == 'complete') {
|
||||
return config('error_code.contract_done_error');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user