Creating model record in multiple locations

Posted 2 months ago by JuanRangel

I am using a ConsultationController to create a Consultation record. I now want to be able to create a consultation record in my RegisterController. What is the best way to handle this?

A few options that come to mind:

  1. Add a method on the User model to handle this. $user->startConsultation()
  2. Use the Consultation::create() in all locations.

What is the best practice here? Which class should have the responsibility of creating a consultation?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.