Member Since 3 Years Ago
4,090 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
@martinbean Good to know I am not alone :) In this case you ignored the adapters. That Data Mapper example has an adapter and get it as a parameter of the mapper: https://designpatternsphp.readthedocs.io/en/latest/Structural/DataMapper/README.html
I think the mapper or Dao should has an interface to make 3rd party services interchangeable.
Still not sure about the update, delete etc other actions. Do you think it is okay to use Dao in controller directly for this actions?
@MARTINBEAN - Let's say I have an event DAO interface and a concrete eventbrite DAO class. I basically get the raw data from the service in it. I also have a Eventbrite adapter class.
I will also hace some business logic for it. So, I have an Event entity class. To transfer the eventbriteadapter response to the entity class I also have Event DTO class. Finally I have an EventController. In the controller I get the raw data via DAO interface (I use Laravel's service container for that), I pass the output of it to the eventbriteadapter (I don't want to call a concrete adapter class in the controller. What would be a better solution? Creating an interface for adapter?) Then, I pass the adapter's result to the event entity. After that, I can call one of entity methods and return it in the controller.
Would it be a good approach or over-engineering? Because I have 5-6 classes/interfaces other than controller.
And what if I want to use CRUD actions of service files? Eventbrite has updateEvent, getAll, deleteEvent etc methods. I didn't get where to put this type of methods. Repository pattern? Huh, it's getting over-complex.
My another concern is having collections for entity chunks. If I call getAll() method I can loop through the data and create an array of objects, but I am not comfortable with it. Laravel's collections would be useful, but I want to separate application layer from domain. What would be a good solution for it?
I am new to this problems. Thanks for your understanding and help!
@MARTINBEAN - Do I need to create one adaptor for each service of each 3rd party? Let's assume that I have two alternative 3rd party services for the same thing:
and they implement a common interface which has get, getAll, store etc methods.
Should I have all these adapters?
@MARTINBEAN - Thank you!
@MARTINBEAN - Thanks for your reply! I don't employ the Adapter pattern directly, but I have services folder which has different subfolders. Each service has its own interface. I implement that interface to create concrete service classes. I use Laravel's service containers and auto-binding features to manage dependencies.
In controllers I get the data from the services and send them to API resources. It seems like a kind of transformer.
The problem is most of service methods returns multi dimensional arrays and it is tricky to validate all the returned data. What if a new implemented concrete service returns a different type of array? API resources can handle that, but I have to validate if each field is set (Am I wrong?)
Do you think it is still a good idea or shall I refactor the whole structure?
leisure_webdev started a new conversation I Need A 'injector' To Inject Plannings To Calendar. Where Should It Be?
I have 2 resources (Collections). One returns a calendar and the other one returns plannings. I need to inject the plannings into the calendar somewhere. The injection is a complex logic. It may have many methods. I don't want to use a controller for that. I think a command or job is not also appropriate. What kind of class should it be and where should I put it?
Thanks for your reply. What about to use Laravel's resources instead of fractal? I used to use it but Laravel has a comparable feature now. I thought to use it but didn't want to put many filtering login in the same file.
leisure_webdev started a new conversation I Need Structural Advices For A Complex Logic To Create A Calendar With Events
In my Laravel REST API project I mainly consume 3rd party APIs. For that, I have a 'Services' folder grouped by modules to send correct parameters to APIs and get the raw data.
I have a calendar API. First I get raw plannings from a 3rd party. I need to filter and restructure this data somehow. I also need to create a calendar (months and days for a calendar year) and inject that events into the calendar days. To keep my CalendarController clean, I need some advices. Shall I consider to use builder pattern? If so, shall I create a new folder in app folder to put that logic? Or shall I put all these logic in the service folder?
I get a raw data, Eliminate free date ranges More filtering e.g removing overlapped events, detecting calendar type (single, multi etc) Extract date ranges to separate days Create a calendar with days Inject events into the calendar's days