src/Entity/Lead.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\LeadRepository")
  6.  */
  7. class Lead
  8. {
  9.     /**
  10.      * @ORM\Id()
  11.      * @ORM\GeneratedValue()
  12.      * @ORM\Column(type="integer")
  13.      */
  14.     private $id;
  15.     
  16.     /**
  17.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="leads", cascade={"persist"})
  18.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
  19.      */
  20.     private $user;
  21.     /**
  22.      * @ORM\Column(type="string", length=40)
  23.      */
  24.     private $ip_address;
  25.     /**
  26.      * @ORM\Column(type="string", length=64)
  27.      */
  28.     private $firstname;
  29.     /**
  30.      * @ORM\Column(type="string", length=64)
  31.      */
  32.     private $lastname;
  33.     /**
  34.      * @ORM\Column(type="string", length=64)
  35.      */
  36.     private $company;
  37.     /**
  38.      * @ORM\Column(type="string", length=64)
  39.      */
  40.     private $job_title;
  41.     /**
  42.      * @ORM\Column(type="string", length=128)
  43.      */
  44.     private $email;
  45.     /**
  46.      * @ORM\Column(type="string", length=15)
  47.      */
  48.     private $phone_business;
  49.     /**
  50.      * @ORM\Column(type="string", length=15)
  51.      */
  52.     private $phone_mobile;
  53.     /**
  54.      * @ORM\Column(type="string", length=64)
  55.      */
  56.     private $address1;
  57.     /**
  58.      * @ORM\Column(type="string", length=64)
  59.      */
  60.     private $address2;
  61.     /**
  62.      * @ORM\Column(type="string", length=32)
  63.      */
  64.     private $city;
  65.     /**
  66.      * @ORM\Column(type="string", length=24)
  67.      */
  68.     private $state;
  69.     /**
  70.      * @ORM\Column(type="string", length=10)
  71.      */
  72.     private $zip;
  73.     /**
  74.      * @ORM\Column(type="string", length=4)
  75.      */
  76.     private $last4;
  77.     /**
  78.      * @ORM\Column(type="string", length=48)
  79.      */
  80.     private $country;
  81.     /**
  82.      * @ORM\Column(type="string", length=64)
  83.      */
  84.     private $website;
  85.     /**
  86.      * @ORM\Column(type="string", length=24)
  87.      */
  88.     private $type_business;
  89.     /**
  90.      * @ORM\Column(type="string", length=24)
  91.      */
  92.     private $type_work;
  93.     /**
  94.      * @ORM\Column(type="datetime")
  95.      */
  96.     private $year_established;
  97.     /**
  98.      * @ORM\Column(type="integer")
  99.      */
  100.     private $employee_size;
  101.     /**
  102.      * @ORM\Column(type="string", length=8)
  103.      */
  104.     private $gender;
  105.     /**
  106.      * @ORM\Column(type="string", length=24)
  107.      */
  108.     private $ethnicity;
  109.     
  110.     /**
  111.      * @ORM\Column(type="string", length=64)
  112.      */
  113.     private $language;
  114.     /**
  115.      * @ORM\Column(type="decimal", precision=10, scale=0)
  116.      */
  117.     private $sales_volume;
  118.     
  119.     /**
  120.      * @ORM\Column(type="string", length=64)
  121.      */
  122.     private $contractor_specialty;
  123.     
  124.     /**
  125.      * @ORM\Column(type="string", length=64)
  126.      */
  127.     private $products_services_specialty;
  128.     /**
  129.      * @ORM\Column(type="string", length=64)
  130.      */
  131.     private $rcs_user;
  132.     /**
  133.      * @ORM\Column(type="string", length=128)
  134.      */
  135.     private $ref_url;
  136.     /**
  137.      * @ORM\Column(type="string", length=196)
  138.      */
  139.     private $user_agent;
  140.     /**
  141.      * @ORM\Column(type="datetime")
  142.      */
  143.     private $created_at;
  144.     
  145.     /**
  146.      * @ORM\Column(type="datetime")
  147.      */
  148.     private $birthday;
  149.     /**
  150.      * @ORM\Column(type="text")
  151.      */
  152.     private $comments;
  153.     
  154.     /**
  155.      * @ORM\ManyToOne(targetEntity="App\Entity\Content", inversedBy="leads", cascade={"persist"})
  156.      * @ORM\JoinColumn(name="content_id", referencedColumnName="id", onDelete="CASCADE")
  157.      */
  158.     private $content;
  159.     
  160.     /**
  161.      * @ORM\ManyToOne(targetEntity="App\Entity\Contact", inversedBy="leads", cascade={"persist"})
  162.      * @ORM\JoinColumn(name="contact_id", referencedColumnName="id", nullable=true)
  163.      */
  164.     private $contact;
  165.     
  166.     /**
  167.      * @ORM\Column(type="integer", nullable=true)
  168.      */
  169.     private $old_client_id;
  170.     
  171.     public function __construct()
  172.     {
  173.         $this->ip_address "";
  174.         $this->firstname "";
  175.         $this->lastname "";
  176.         $this->company "";
  177.         $this->job_title "";
  178.         $this->email "";
  179.         $this->phone_business "";
  180.         $this->phone_mobile "";
  181.         $this->address1 "";
  182.         $this->address2 "";
  183.         $this->city "";
  184.         $this->state "";
  185.         $this->zip "";
  186.         $this->last4 "";
  187.         $this->country "";
  188.         $this->website "";
  189.         $this->type_business "";
  190.         $this->type_work "";
  191.         $this->year_established = new \DateTime();
  192.         $this->employee_size 0;
  193.         $this->gender "";
  194.         $this->ethnicity "";
  195.         $this->language "";
  196.         $this->sales_volume 0;
  197.         $this->contractor_specialty "";
  198.         $this->products_services_specialty "";
  199.         $this->rcs_user "";
  200.         $this->ref_url "";
  201.         $this->user_agent "";
  202.         $this->created_at = new \DateTime();
  203.         $this->birthday null;
  204.         $this->comments "";
  205.         $this->old_client_id null;
  206.     }
  207.     public function getId()
  208.     {
  209.         return $this->id;
  210.     }
  211.     
  212.     public function getUser(): ?User
  213.     {
  214.         return $this->user;
  215.     }
  216.     public function setUser(?User $user null): self
  217.     {
  218.         $this->user $user;
  219.         
  220.         return $this;
  221.     }
  222.     
  223.     public function getContent(): ?Content
  224.     {
  225.         return $this->content;
  226.     }
  227.     public function setContent(?Content $content): self
  228.     {
  229.         $this->content $content;
  230.         return $this;
  231.     }
  232.     
  233.     public function getContact(): ?Contact
  234.     {
  235.         return $this->contact;
  236.     }
  237.     public function setContact(?Contact $contact null): self
  238.     {
  239.         $this->contact $contact;
  240.         
  241.         return $this;
  242.     }
  243.     public function getIpAddress(): ?string
  244.     {
  245.         return $this->ip_address;
  246.     }
  247.     public function setIpAddress(string $ip_address null): self
  248.     {
  249.         if (is_null($ip_address)) {
  250.             $ip_address "";
  251.         }
  252.         
  253.         $this->ip_address $ip_address;
  254.         return $this;
  255.     }
  256.     public function getFirstname(): ?string
  257.     {
  258.         return $this->firstname;
  259.     }
  260.     public function setFirstname(string $firstname null): self
  261.     {
  262.         if (is_null($firstname)) {
  263.             $firstname "";
  264.         }
  265.         
  266.         $this->firstname $firstname;
  267.         return $this;
  268.     }
  269.     public function getLastname(): ?string
  270.     {
  271.         return $this->lastname;
  272.     }
  273.     public function setLastname(string $lastname null): self
  274.     {
  275.         if (is_null($lastname)) {
  276.             $lastname "";
  277.         }
  278.         
  279.         $this->lastname $lastname;
  280.         return $this;
  281.     }
  282.     public function getCompany(): ?string
  283.     {
  284.         return $this->company;
  285.     }
  286.     public function setCompany(string $company null): self
  287.     {
  288.         if (is_null($company)) {
  289.             $company "";
  290.         }
  291.         
  292.         $this->company $company;
  293.         return $this;
  294.     }
  295.     public function getJobTitle(): ?string
  296.     {
  297.         return $this->job_title;
  298.     }
  299.     public function setJobTitle(string $job_title null): self
  300.     {
  301.         if (is_null($job_title)) {
  302.             $job_title "";
  303.         }
  304.         
  305.         $this->job_title $job_title;
  306.         return $this;
  307.     }
  308.     public function getEmail(): ?string
  309.     {
  310.         return $this->email;
  311.     }
  312.     public function setEmail(string $email null): self
  313.     {
  314.         if (is_null($email)) {
  315.             $email "";
  316.         }
  317.         
  318.         $this->email $email;
  319.         return $this;
  320.     }
  321.     public function getPhoneBusiness(): ?string
  322.     {
  323.         return $this->phone_business;
  324.     }
  325.     public function setPhoneBusiness(string $phone_business null): self
  326.     {
  327.         if (is_null($phone_business)) {
  328.             $phone_business "";
  329.         }
  330.         
  331.         $this->phone_business $phone_business;
  332.         return $this;
  333.     }
  334.     public function getPhoneMobile(): ?string
  335.     {
  336.         return $this->phone_mobile;
  337.     }
  338.     public function setPhoneMobile(string $phone_mobile null): self
  339.     {
  340.         if (is_null($phone_mobile)) {
  341.             $phone_mobile "";
  342.         }
  343.         
  344.         $this->phone_mobile $phone_mobile;
  345.         return $this;
  346.     }
  347.     public function getAddress1(): ?string
  348.     {
  349.         return $this->address1;
  350.     }
  351.     public function setAddress1(string $address1 null): self
  352.     {
  353.         if (is_null($address1)) {
  354.             $address1 "";
  355.         }
  356.         
  357.         $this->address1 $address1;
  358.         return $this;
  359.     }
  360.     public function getAddress2(): ?string
  361.     {
  362.         return $this->address2;
  363.     }
  364.     public function setAddress2(string $address2 null): self
  365.     {
  366.         if (is_null($address2)) {
  367.             $address2 "";
  368.         }
  369.         
  370.         $this->address2 $address2;
  371.         return $this;
  372.     }
  373.     public function getCity(): ?string
  374.     {
  375.         return $this->city;
  376.     }
  377.     public function setCity(string $city null): self
  378.     {
  379.         if (is_null($city)) {
  380.             $city "";
  381.         }
  382.         
  383.         $this->city $city;
  384.         return $this;
  385.     }
  386.     public function getState(): ?string
  387.     {
  388.         return $this->state;
  389.     }
  390.     public function setState(string $state ""): self
  391.     {
  392.         if (is_null($state)) {
  393.             $state "";
  394.         }
  395.         
  396.         $this->state $state;
  397.         return $this;
  398.     }
  399.     public function getZip(): ?string
  400.     {
  401.         return $this->zip;
  402.     }
  403.     public function setZip(string $zip null): self
  404.     {
  405.         if (is_null($zip)) {
  406.             $zip "";
  407.         }
  408.         
  409.         $this->zip $zip;
  410.         return $this;
  411.     }
  412.     public function getLast4(): ?string
  413.     {
  414.         return $this->last4;
  415.     }
  416.     public function setLast4(string $last4 null): self
  417.     {
  418.         if (is_null($last4)) {
  419.             $last4 "";
  420.         }
  421.         
  422.         $this->last4 $last4;
  423.         return $this;
  424.     }
  425.     public function getCountry(): ?string
  426.     {
  427.         return $this->country;
  428.     }
  429.     public function setCountry(string $country null): self
  430.     {
  431.         if (is_null($country)) {
  432.             $country "";
  433.         }
  434.         
  435.         $this->country $country;
  436.         return $this;
  437.     }
  438.     public function getWebsite(): ?string
  439.     {
  440.         return $this->website;
  441.     }
  442.     public function setWebsite(string $website null): self
  443.     {
  444.         if (is_null($website)) {
  445.             $website "";
  446.         }
  447.         
  448.         $this->website $website;
  449.         return $this;
  450.     }
  451.     public function getTypeBusiness(): ?string
  452.     {
  453.         return $this->type_business;
  454.     }
  455.     public function setTypeBusiness(string $type_business ""): self
  456.     {
  457.         if (is_null($type_business)) {
  458.             $type_business "";
  459.         }
  460.         
  461.         $this->type_business $type_business;
  462.         return $this;
  463.     }
  464.     public function getTypeWork(): ?string
  465.     {
  466.         return $this->type_work;
  467.     }
  468.     public function setTypeWork(string $type_work null): self
  469.     {
  470.         if (is_null($type_work)) {
  471.             $type_work "";
  472.         }
  473.         
  474.         $this->type_work $type_work;
  475.         return $this;
  476.     }
  477.     public function getYearEstablished(): ?\DateTimeInterface
  478.     {
  479.         return $this->year_established;
  480.     }
  481.     public function setYearEstablished(\DateTimeInterface $year_established null): self
  482.     {
  483.         if (is_null($year_established)) {
  484.             $year_established = new \DateTime("now");
  485.         }
  486.         
  487.         $this->year_established $year_established;
  488.         return $this;
  489.     }
  490.     public function getEmployeeSize(): ?int
  491.     {
  492.         return $this->employee_size;
  493.     }
  494.     public function setEmployeeSize(int $employee_size null): self
  495.     {
  496.         if (is_null($employee_size)) {
  497.             $employee_size 0;
  498.         }
  499.         
  500.         $this->employee_size $employee_size;
  501.         return $this;
  502.     }
  503.     public function getGender(): ?string
  504.     {
  505.         return $this->gender;
  506.     }
  507.     public function setGender(string $gender null): self
  508.     {
  509.         if (is_null($gender)) {
  510.             $gender "";
  511.         }
  512.         
  513.         $this->gender $gender;
  514.         return $this;
  515.     }
  516.     public function getEthnicity(): ?string
  517.     {
  518.         return $this->ethnicity;
  519.     }
  520.     public function setEthnicity(string $ethnicity null): self
  521.     {
  522.         if (is_null($ethnicity)) {
  523.             $ethnicity "";
  524.         }
  525.         
  526.         $this->ethnicity $ethnicity;
  527.         return $this;
  528.     }
  529.     public function getLanguage(): ?string
  530.     {
  531.         return $this->language;
  532.     }
  533.     public function setLanguage(string $language null): self
  534.     {
  535.         if (is_null($language)) {
  536.             $language "";
  537.         }
  538.         
  539.         $this->language $language;
  540.         return $this;
  541.     }
  542.     public function getSalesVolume()
  543.     {
  544.         return $this->sales_volume;
  545.     }
  546.     public function setSalesVolume($sales_volume null): self
  547.     {
  548.         if (is_null($sales_volume)) {
  549.             $sales_volume 0;
  550.         }
  551.         
  552.         $this->sales_volume $sales_volume;
  553.         return $this;
  554.     }
  555.     
  556.     public function getContractorSpecialty(): ?string
  557.     {
  558.         return $this->contractor_specialty;
  559.     }
  560.     public function setContractorSpecialty(string $contractor_specialty null): self
  561.     {
  562.         if (is_null($contractor_specialty)) {
  563.             $contractor_specialty "";
  564.         }
  565.         
  566.         $this->contractor_specialty $contractor_specialty;
  567.         return $this;
  568.     }
  569.     
  570.     public function getProductsServicesSpecialty(): ?string
  571.     {
  572.         return $this->products_services_specialty;
  573.     }
  574.     public function setProductsServicesSpecialty(string $products_services_specialty null): self
  575.     {
  576.         if (is_null($products_services_specialty)) {
  577.             $products_services_specialty "";
  578.         }
  579.         
  580.         $this->products_services_specialty $products_services_specialty;
  581.         return $this;
  582.     }
  583.     public function getRcsUser(): ?string
  584.     {
  585.         return $this->rcs_user;
  586.     }
  587.     public function setRcsUser(string $rcs_user null): self
  588.     {
  589.         if (is_null($rcs_user)) {
  590.             $rcs_user "";
  591.         }
  592.         
  593.         $this->rcs_user $rcs_user;
  594.         return $this;
  595.     }
  596.     public function getRefUrl(): ?string
  597.     {
  598.         return $this->ref_url;
  599.     }
  600.     public function setRefUrl(string $ref_url null): self
  601.     {
  602.         if (is_null($ref_url)) {
  603.             $ref_url "";
  604.         }
  605.         
  606.         $this->ref_url $ref_url;
  607.         return $this;
  608.     }
  609.     public function getUserAgent(): ?string
  610.     {
  611.         return $this->user_agent;
  612.     }
  613.     public function setUserAgent(string $user_agent null): self
  614.     {
  615.         if (is_null($user_agent)) {
  616.             $user_agent "";
  617.         }
  618.         
  619.         $this->user_agent $user_agent;
  620.         return $this;
  621.     }
  622.     public function getCreatedAt(): ?\DateTimeInterface
  623.     {
  624.         return $this->created_at;
  625.     }
  626.     public function setCreatedAt(\DateTimeInterface $created_at null): self
  627.     {
  628.         if (is_null($created_at)) {
  629.             $created_at = new \DateTime("now");
  630.         }
  631.         
  632.         $this->created_at $created_at;
  633.         return $this;
  634.     }
  635.     
  636.     public function getBirthday(): ?\DateTimeInterface
  637.     {
  638.         return $this->birthday;
  639.     }
  640.     public function setBirthday(\DateTimeInterface $birthday null): self
  641.     {
  642.         $this->birthday $birthday;
  643.         return $this;
  644.     }
  645.     public function getComments(): ?string
  646.     {
  647.         return $this->comments;
  648.     }
  649.     public function setComments(string $comments null): self
  650.     {
  651.         if (is_null($comments)) {
  652.             $comments "";
  653.         }
  654.         
  655.         $this->comments $comments;
  656.         return $this;
  657.     }
  658.     
  659.     //Comments are being used to store custom fields. This function returns them as an assoc array.
  660.     public function getCustomFields(): ?array
  661.     {
  662.         $return null;
  663.         if($this->comments) {
  664.             $return json_decode($this->commentstrue);
  665.             //Format the field title
  666.             if($return) {
  667.                 if(isset($return["custom_fields"])) {
  668.                     //new way of storing
  669.                     $return $return["custom_fields"];
  670.                 }
  671.                 foreach($return as $key => $value) {
  672.                     unset($return[$key]);
  673.                     $return[ucwords(str_replace("_"" "$key))] = $value;
  674.                 }
  675.             }
  676.             else {
  677.                 //Not json_encoded, just normal comments
  678.                 $return = [
  679.                     "Comments" => $this->comments
  680.                 ];
  681.             }
  682.         }
  683.         return $return;
  684.     }
  685.     public function getCustomFieldMediaIDs(): ?array
  686.     {
  687.         $return null;
  688.         if($this->comments) {
  689.             $return json_decode($this->commentstrue);
  690.             if($return) {
  691.                 if(isset($return["custom_media_ids"])) {
  692.                     $return $return["custom_media_ids"];
  693.                     foreach($return as $key => $value) {
  694.                         unset($return[$key]);
  695.                         $return[ucwords(str_replace("_"" "$key))] = $value;
  696.                     }
  697.                 }
  698.             }
  699.         }
  700.         return $return;
  701.     }
  702.     
  703.     public function getOldClientId(): ?int
  704.     {
  705.         return $this->old_client_id;
  706.     }
  707.     public function setOldClientId(int $old_client_id): self
  708.     {
  709.         $this->old_client_id $old_client_id;
  710.         return $this;
  711.     }
  712.     
  713.     public function __toString ()
  714.     {
  715.         if($this->firstname) {
  716.             $return $this->firstname;
  717.             if($this->lastname)
  718.             {
  719.                 $return .= " " $this->lastname;
  720.             }
  721.             return $return;
  722.         }
  723.         return $this->email $this->email '';
  724.     }
  725. }