I am having trouble getting a number instead of a string in my query. I have two tables and a pivot table.

**File**:

* id
* name
* document
* language

**Role**:

* id
* name (admin, partner, dealer, associate)

**File\_role**:

* id
* file\_id
* role\_id

I want to display all the files for the 'dealer' role so i tried this:

```
$file_role = File_Role::where('role_id', '=', $id)->get('file_id');
$file = File::where('id', '=', $file_role)->get();
dd($file_role);

```

However it keeps returning errors on:

```
$file = File::where('id', '=', $file_role)->get();

```

The error is:

> 
> SQLSTATE[HY093]: Invalid parameter number.
> 
> 
> 

The query below that is:

```
select * from `file` where `id` = {"file_id":1}.

```

Any ideas how I can get a number instead of `"file_id":1`?