I get an error on line 11 of this code in Laravel saying:
syntax error, unexpected '->' (T_OBJECT_OPERATOR)
Here is the code of ClientController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Title as Title;
class ClientController extends Controller
{
public function __construct( Title $titles) {
$this->titles = titles->all();
}
public function di() {
dd($this->titles);
}
}
The Title:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Title extends ReadOnlyBase
{
protected $titles_array = ['Mr', 'Mrs', 'Ms', 'Dr', 'Mx'];
}
The ReadOnlyBase:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ReadOnlyBase
{
//
protected $titles_array = [];
public function all()
{
return $this->titles_array;
}
public function get( $id )
{
return $this->titles_array[$id];
}
}
And the web.php:
Route::get('/di', 'ClientController@di');
I wrote the code exactly as a lynda lesson on Laravel, and yet I get an error.