Question: I have a table Foo

id 

```
1 
2 
3 
4 
5

```

i have a table Bar

```
foo_id = 1 test = 1
foo_id = 2 test = 0
foo_id = 4 test = 1
foo_id = 5 test = 1

```

I want to retrieve id from foo where bar test = 0 or not exist in bar.

I have

```
$id = Foo::with('bar')->whereHas('bar', function ($q)
  {$q->where('test', '=', 0)
  ->orWhereNull(foo_id???????);})
->get();

```

How can i write this down?

Answer: 
You can coerce a number in JavaScript to a particular numeric type by making use of [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)'s, specifically, [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array):

```js
function toShort(number) {
  const int16 = new Int16Array(1)
  int16[0] = number
  return int16[0]
}

console.log(toShort(65512))
```
Another option is to understand that C# is overflowing the number so you can just check it's over the max value for a short which is 32767 (07FFF) and subtract the max value of an int+1 which is 65536 (0x10000). For example:

```js
var number = 65512
var shortValue = number > 0x7FFF ? number - 0x10000 : number;
console.log(shortValue);
```