Question: I want to 

SELECT events.id = scan.event\_id IF Scan.student\_id MATCH user.student\_id SHOW events.id and events.name

But my code dint work, it blank screen nothing happen to show
so blind :|

Controller

```php
    public function pdftranscript($id)
    {
        $users = DB::table('users')
            ->join('scan', 'users.student_id', '=', 'scan.student_id')
            ->join('events', 'scan.event_id', '=', 'events.id')
            ->select('users.*', 'events.m_event_name', 'scan.event_id')
            ->get();

```

This blade

```php
        @foreach($user as $user)
        <tr>
            <td>{{$user->student_id}}</td>
            <td>{{$user->name}}</td>
            @foreach($event as $event)
            <td>{{$event->m_event_name}}</td>
            @endforeach
        <tr>
        @endforeach

```

Answer: 
There are two places you can use variables here: inside the compose file itself, and inside the containers created by`docker-compose`.

The `.env` file will be used by `docker-compose` to adjust the environment of the `docker-compose` command itself. This is useful for variable inside the yaml file that need to be expanded, or variables used by compose itself. For more on the latter, see [the compose CLI variables docs](https://docs.docker.com/compose/reference/envvars/).

Defining an `env_file` inside the yaml will take environment variables from the file and inject them into the container. That makes it visible to your application, but cannot be used for variables inside your yaml that you want `docker-compose` to expand since that variable expansion happens before the `env_file` contents are parsed.
Docker-compose need to be defined everything explicitly, consider it as a `docker run parameter`, it only applies those configurations or parameter on each container that is defined in the docker-compose file.

So one should avoid overriding ENV if they are already declared in Dockerfile so that is the why you need to explicitly define these configurations for your self.

when we build docker we set some default configuration in the docker-image, but `docker run command` and `docker-compose` provide the functionality to override these to change that take effect when the image starts up as a container.

> 
> A service definition contains configuration that is applied to each
>  container started for that service, much like passing command-line
>  parameters to docker container create. Likewise, network and volume
>  definitions are analogous to docker network create and docker volume
>  create.
> 
> 
> 

[compose-file](https://docs.docker.com/compose/compose-file/)

**env\_file**

Add environment variables from a file. Can be a single value or a list.

> 
> If you have specified a Compose file with `docker-compose -f FILE`,
>  paths in `env_file` are relative to the directory that file is in.
> 
> 
> Environment variables declared in the environment section override
>  these values – this holds true even if those values are empty or
>  undefined.
> 
> 
> 

```
env_file: .env

```