This is my Availability model
namespace App\Models\candidate;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use \App\Helpers\EncryptionHelper;
class Availability extends Model
{
use HasFactory;
use SoftDeletes;
private $encryption;
private $encryptionKey;
protected $fillable = ['shift_id', 'job_role_id', 'available_date', 'created_by', 'id'];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->encryption = EncryptionHelper::get_instance();
$this->encryptionKey = "availability";
}
public function getIdAttribute()
{
return $this->encryption->encrypt($this->attributes['id'], $this->encryptionKey);
// return $this->encryption->encrypt($this->attributes['id'], $this->encryptionKey);
}
public function decryptId($id = "")
{
if ($id) {
return $this->encryption->decrypt($id, $this->encryptionKey);
} else {
return $this->encryption->decrypt($this->attributes['id'], $this->encryptionKey);
}
}
public function resolveRouteBinding($value, $field = null)
{
$value = $this->encryption->decrypt($value, $this->encryptionKey);
return $this->where('id', $value)->firstOrFail();
}
}
I need to send a notification when the user updates the value. I have a notification AlertAdmin notification that implements ShouldQueue. While processing queue I got the error Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model [App\Models\candidate\Availability]. When I debug the code I can find that the model id is in decrypted form. while restoring the model from a notification I can find that id is mismatched from the db id value. How to solve this issue.I'm using laravel 9.