Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
add viewData support
Browse files Browse the repository at this point in the history
  • Loading branch information
Qoraiche committed May 24, 2019
1 parent 35c0a37 commit bd205ae
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/mailEclipse.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,13 @@ static protected function mailablesList()
$mailable_data = self::buildMailable($mailableClass);

if (!is_null(self::handleMailableViewDataArgs($mailableClass))) {

$mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data);

// dd($mailable_view_data);
} else {
$mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data);
}

$mailable_data = self::buildMailable($mailableClass);

$fqcns[$i]['data'] = $mailable_data;
$fqcns[$i]['markdown'] = self::getMarkdownViewName($mailable_data);
$fqcns[$i]['name'] = $name;
Expand Down Expand Up @@ -754,16 +752,14 @@ static private function getMailableViewData($mailable, $mailable_data)
$withFuncData = collect($obj->viewData)->keys();

$mailableData = collect($classProps)->merge($withFuncData);

// dd($mailableData);

$data = $mailableData->map(function($parameter) use ($mailable_data){

return [
'key' => $parameter,
'value' => $mailable_data->$parameter,
'data' => self::viewDataInspect($mailable_data->$parameter),
];
return [
'key' => $parameter,
'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null,
'data' => property_exists($mailable_data, $parameter) ? self::viewDataInspect($mailable_data->$parameter) : null,
];

});

Expand All @@ -774,8 +770,6 @@ static private function getMailableViewData($mailable, $mailable_data)

static protected function viewDataInspect($param){

// dd($param);

if ( $param instanceof \Illuminate\Database\Eloquent\Model ){

return [
Expand Down

0 comments on commit bd205ae

Please sign in to comment.