Here is my code:
return PDF::loadFile($url)
->setPaper('a4')
->setOption('margin-top', 10)
->stream('somefile.pdf');
As I am calling this method on multiple locations, is there some kind of option to call it in a way like this?
return PDF::loadFile($url)
->callSettings()
->stream('somefile.pdf');
Where the settings are ->setPaper('a4')->setOption('margin-top', 10)
.
It's easy. Just implement a new callSettings()
method in PDF
class, that calls those methods and returns $this
:
public function callSettings()
{
$this->setPaper('a4')
->setOption('margin-top', 10);
return $this;
}