Hi
how can I avoid this 'error'
Argument '1' passed to __construct() is expected to be of type App\Models\UserDoc, Illuminate\Database\Eloquent\Collection given
Here is the code:
$userDoc = UserDoc::find(Crypt::decrypt($this->encryptedData));
event(new UserDocReceiverHasSignedEvent($userDoc));
Technically I can somewhat understand the error because the doc says this:
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array|string $columns
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TModel> : TModel|null)
*/
The comment contradicts the return value a little IMO
but in reality find() always return one model or null - yes, if called with an array it can return a collection