1

I'm trying to get a config value from my custom helper in laravel 5.6:

function current(string $conn=null){
    return $conn.config('server.current');
}

but I get this error:

Can't use function return value in write context in...

There is any other way to share it between helpers?

Laravel seems to not show config values in helpers.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Vixed
  • 3,429
  • 5
  • 37
  • 68
  • 1
    `.` is the concatenation operator in PHP. If you're attempting to access an array key, then it would be `$conn['config']`. I'd suggest making sure that $conn is not null/an array before you attempt that, though, since that's the default value. – aynber Sep 06 '18 at 13:43
  • @aynber no, I'm concatenating the values... that's what I want. – Vixed Sep 06 '18 at 13:47
  • show us where you called this function.. it sounds like there is an problem.. not in the function declaration – Mihai Matei Sep 06 '18 at 13:53
  • What exactly are you trying to achieve? – Jerodev Sep 06 '18 at 13:54
  • Try calling the config function and see what it returns. `Log::info(config('server.current')); Log::info($conn);`. They may not be returning what you think they are. – aynber Sep 06 '18 at 13:54

1 Answers1

3

current() is an existing function http://php.net/manual/en/function.current.php

Clément Baconnier
  • 5,718
  • 5
  • 29
  • 55