leisure_webdev

leisure_webdev

Member Since 3 Years Ago

Experience Points 30,910
Experience Level 7

4,090 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 307
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    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.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

26 Apr
3 months ago

leisure_webdev left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

@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?

leisure_webdev left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

@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!

23 Apr
3 months ago

leisure_webdev left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

@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:

ServiceX

ServiceY

and they implement a common interface which has get, getAll, store etc methods.

Should I have all these adapters?

ServiceXGetAdapter

ServiceXGetAllAdapter

ServiceXStoreAdapter

ServiceYGetAdapter

ServiceYGetAllAdapter

ServiceYStoreAdapter

19 Apr
4 months ago

leisure_webdev left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

@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?

Regards

18 Apr
4 months ago

leisure_webdev started a new conversation I Need A 'injector' To Inject Plannings To Calendar. Where Should It Be?

Hello,

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?

Best Regards.

11 Apr
4 months ago

leisure_webdev left a reply on I Need Structural Advices For A Complex Logic To Create A Calendar With Events

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.

08 Apr
4 months ago

leisure_webdev started a new conversation I Need Structural Advices For A Complex Logic To Create A Calendar With Events

Hi,

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?

Basically,

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

Regards