Episode 21 in Laravel From Scratch 5.7, the resolved class does not return the value passed to its constructor. It's at 12:30 in the episode, linkk follows: https://laracasts.com/series/laravel-from-scratch-2018/episodes/21
I have tried using full path to the class everywhere it's referenced - but no difference.
Twitter class in App\Services:
.....
<?php
namespace App\Services;
class Twitter
{
protected $apiKey;
public function _construct($apiKey)
{
$this->apiKey = $apiKey;
}
}
......
It is invoked in web.php: .....
app()->singleton('twitter', function() {
return new App\Services\Twitter('adsadsadasdfd');
});
......
In ProjectsController (used in Jeffrey Wray's example) the class is invoked like so: .....
use App\Services\Twitter;
......
And then called further down: ......
public function show(Project $project)
{
$twitter = app('twitter');
dd($twitter);
}
......
This is returned:
>>Twitter {#219 ▼
>> #apiKey: null
>>}
It should return:
>>Twitter {#219 ▼
>> #apiKey: "adsadsadasdfd"
>>}