Refactor Requestable@cancelRequest() firm to admit a user_id so we can cancel a request of whatever user we want

This commit is contained in:
Ivan Nieto Vivanco 2023-06-27 17:13:11 -06:00
parent b647a8fcd2
commit eb4d764601

View file

@ -38,8 +38,12 @@ trait Requestable
$this->requests()->where('user_id', Auth::id())->delete();
}
public function cancelRequest()
public function cancelRequest($user_id = null)
{
$this->requests()->where('user_id', Auth::id())->update(['canceled_at' => \Carbon\Carbon::now()]);
if (!$user_id){
$user_id = Auth::id();
}
$this->requests()->where('user_id', $user_id)->update(['canceled_at' => \Carbon\Carbon::now()]);
}
}