Question: How to route to another url with a parameter from laravel's `app/console/commands/myCommand.php's` handler() method?

I want to route to another url/page/route with a parameter from handle() method of custom made command file which(route) later will call a controller and that parameter passed by handle() via route() will be handle() there in controller.

```
app/console/commands/myCommand.php

public function handle()
    {
        $sale_days = SaleDay::latest()->first();
        Log::info('test command file');

        $latest_date = $sale_days->date;
        // $request = Request::create('/game/end/day/'.$latest_date, 'get');
        // '<a href=' . route('game.endday', $latest_date) . '></a>';
        // return $request;
        return redirect()->to('game.endday', $latest_date);
    }

```

```
web.php

    Route::get('/game/end/day/{date}', 'SaleDayController@endday')->name('game.endday');

```

```
controller 

public function endday($date) {

    // $date = \Artisan::call('auto_day:close');
    Log::info("command endday module in saledaycontroller");
    $new_Date=Carbon::create($date);
    $prev_sale_day=$this->daySaleService->endDay($date);

    $new_sale_day=$this->daySaleService->firstOrCreate($new_Date->addDays(1));
    $this->daySaleService->changeCurrentDay($new_sale_day->id);
    $this->daySaleService->shiftDayGameSales($new_sale_day->id,$prev_sale_day->id);
    Log::info("command endday module in saledaycontroller ENDDDDD");

    return redirect()->route('game.sale');
}

```

the handle function is not working properly, How can I route from handle() method with a parameter

Answer: 
There are several options. For instance

```
>file_name

```

ensures that you have afterwards an **empty** file named `file_name`. If you write instead

```
touch file_name

```

then `file_name` will only be generated if it did not exist before. If it existed, it gets its time stamp updated.

You can also do a

```
[ -f file_name ] || touch file_name

```

This would generate `file_name`, if it did not exist, but leave the time stamp unchanged if the file existed already.

You can also fill the file with information contained in your script, by using a so-called *here-document*:

```
cat >file_name <<'END_OF_THE_WORLD'
Hello
$PATH
Goodbye
END_OF_THE_WORLD

```

The single quotes ensure that your file really contains the literal string `$PATH`, i.e. no parameter expansion is performed on the text.
You could use:

```
echo "file content" > file.txt

```

Or, if you want to see the content while writing the file:

```
echo "file content" | tee file.txt

```