-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
342 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\View\Components\Widgets\Previews; | ||
|
||
use App\Models\Campaign; | ||
use App\Models\CampaignDashboardWidget; | ||
use App\Models\Entity; | ||
use App\Models\MiscModel; | ||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Body extends Component | ||
{ | ||
public Campaign $campaign; | ||
public CampaignDashboardWidget $widget; | ||
public Entity $entity; | ||
public MiscModel $model; | ||
|
||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct( | ||
Campaign $campaign, | ||
CampaignDashboardWidget $widget, | ||
Entity $entity, | ||
MiscModel $model, | ||
) { | ||
$this->campaign = $campaign; | ||
$this->widget = $widget; | ||
$this->entity = $entity; | ||
$this->model = $model; | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view('components.widgets.previews.body'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace App\View\Components\Widgets\Previews; | ||
|
||
use App\Facades\Img; | ||
use App\Models\Campaign; | ||
use App\Models\CampaignDashboardWidget; | ||
use App\Models\Entity; | ||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Head extends Component | ||
{ | ||
public Campaign $campaign; | ||
public CampaignDashboardWidget $widget; | ||
public Entity $entity; | ||
|
||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct( | ||
Campaign $campaign, | ||
CampaignDashboardWidget $widget, | ||
Entity $entity, | ||
) { | ||
$this->campaign = $campaign; | ||
$this->widget = $widget; | ||
$this->entity = $entity; | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view('components.widgets.previews.head') | ||
->with('image', $this->headerImage()); | ||
} | ||
|
||
protected function headerImage(): null|string | ||
{ | ||
if ($this->widget->conf('entity-header') && $this->campaign->boosted() && $this->entity->header_image) { | ||
return $this->entity->thumbnail(1200, 400, 'header_image'); | ||
} elseif ($this->widget->conf('entity-header') && $this->campaign->boosted() && $this->widget->entity->header) { | ||
return $this->entity->header->path; | ||
} elseif ($this->entity->image) { | ||
return Img::crop(1200, 400)->url($this->entity->image->path); | ||
} elseif ($this->entity->child->image) { | ||
return $this->entity->child->thumbnail(400); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.