From a4174e9cb85ce5929760d5b57297f161dfcb05da Mon Sep 17 00:00:00 2001 From: Yassine Date: Tue, 26 Mar 2019 15:43:17 +0100 Subject: [PATCH] add constructor array type --- src/mailEclipse.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/mailEclipse.php b/src/mailEclipse.php index 97017d7..af993ca 100644 --- a/src/mailEclipse.php +++ b/src/mailEclipse.php @@ -637,6 +637,7 @@ static public function handleMailableViewDataArgs($mailable) if ( $param->getType() !== null ) { + if ( class_exists( $param->getType()->getName() ) ) { $parameters = [ @@ -644,6 +645,14 @@ static public function handleMailableViewDataArgs($mailable) 'instance' => $param->getType()->getName() ]; + + } elseif ($param->getType()->getName() == 'array') { + + $parameters = [ + 'is_array' => true, + 'arg' => $param->getName() + ]; + } else { $parameters = $param->name; @@ -661,15 +670,28 @@ static public function handleMailableViewDataArgs($mailable) $factoryStates = []; - if ( is_array($arg) && $arg['is_instance'] ){ + if ( is_array($arg) ){ + + if ( isset($arg['is_instance']) ){ + + if ( isset($eloquentFactory[$arg['instance']]) ) { + + $filteredparams[] = factory($arg['instance'])->states($factoryStates)->create(); + + } else { + $filteredparams[] = app($arg['instance']); + } - if ( isset($eloquentFactory[$arg['instance']]) ) { + } elseif( isset($arg['is_array']) ){ - $filteredparams[] = factory($arg['instance'])->states($factoryStates)->create(); + $filteredparams[] = []; - } else { - $filteredparams[] = app($arg['instance']); - } + } else { + + return; + } + + } else { @@ -692,11 +714,6 @@ static public function handleMailableViewDataArgs($mailable) } - /** - * - * - */ - static private function getMailableViewData($mailable) {