For try catchtry
/catch
, statements you should ask yourself,: what are you trying to achieve? Do you need to handle the error differently in one controller compared to the rest of the application? ifIf yes, then wrap the entire contents of your method.
If no.. Laravel, Laravel implements a global error handler.. youYou simply need to throw your exceptions and laravelLaravel handles the display of the errors.
As for you unit testing, I am only learning PHPUnit at the moment but judging. Judging by your code, I believe you should take some particular emphasis on learning the S.O.L.I.D principles. https://scotchS.io/bar-talk/s-o-l-i-d-the-first-five-principles-of-object-oriented-designO.L.I.D principles.
When you abide by these principles you will ensure your code is testable. To be testable your methods and objects need to have a single responsibility. E.g., such as taking requests (controller), validation (Request objects in laravel -http://laravel.com/docs/5.0/requests)Request objects in Laravel and saving data (Models).
As for Doc blocks Refer, refer to something like this. http://phpdoc2cheatsheet.com/this.
Comment you code often. For For methods I always specify in the first line a description of what the method does. (it should have a single responsibility). Then any parameters/arguments it takes (@param). Then Then any data it returns (@return). Specify the data type or 'void' if it returns nothing. Then Then finally any exceptions the method throws
I hope this helps.