In our last instalment we spoke about how we can use data objects and data object factories to escape what I call “array hell”, a place where we have no idea what is in something passed to a method and there is no context or strictness about them. The purpose of these commands are to create single classes that have one purpose and one purpose only: to write data to any external service.
Make the following changes so your data object looks like the below: $this->title, 'content' => $this->content, 'published' => $this->published, 'published_at' => $this->publishedAt ]; }} Using this toArray method it allows us to turn our Data Object into something that Eloquent can understand and work with.
It also means that if we remove the domain service provider from config/app.php then we are also removing these bindings automatically.