Skip to content

Commit

Permalink
few more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tushargugnani committed Jan 31, 2023
1 parent 88c8d40 commit 0cc669a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
8 changes: 7 additions & 1 deletion resources/views/components/smart-ad-component.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
@isset($smartAd)
<div class="smart-banner-temp" banner-slug="{{$smartAd->slug}}">
{!! $smartAd->body !!}
@if($smartAd->adType == 'HTML')
{!! $smartAd->body !!}
@elseif($smartAd->adType == 'IMAGE')
<a href="{{($smartAd->imageUrl ? $smartAd->imageUrl : '#')}}" target="_blank">
<img src="{{asset('storage/'.$smartAd->image)}}" alt="{{$smartAd->imageAlt}}" />
</a>
@endif
</div>
@endisset
24 changes: 16 additions & 8 deletions src/Http/Controllers/SmartAdManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,24 @@ public function edit(SmartAd $smartAd){

public function update(StoreSmartAdRequest $request, SmartAd $smartAd){

if(isset($request->image)){
$imagePath = $request->file('image')->store('image', 'public');
$smartAd->image = $imagePath;
}

$smartAd->name = $request->name;
$smartAd->body = isset($request->body) ? $request->body : null;
$smartAd->imageUrl = isset($request->imageUrl) ? $request->imageUrl : null;
$smartAd->imageAlt = isset($request->imageAlt) ? $request->imageAlt : null;
$smartAd->placements = $request->placements;
if($request->adType == 'HTML'){
$smartAd->image = null;
$smartAd->imageUrl = null;
$smartAd->imageAlt = null;
$smartAd->body = $request->body;
}elseif($request->adType == 'IMAGE'){
if(isset($request->image)){
$imagePath = $request->file('image')->store('image', 'public');
$smartAd->image = $imagePath;
}

$smartAd->imageUrl = isset($request->imageUrl) ? $request->imageUrl : null;
$smartAd->imageAlt = isset($request->imageAlt) ? $request->imageAlt : null;
}
$smartAd->adType = $request->adType;

$smartAd->save();
return redirect("/smart-ad-manager/ads/{$smartAd->id}")->with(['message' => 'Ad Edited', 'color' => 'green']);
}
Expand Down

0 comments on commit 0cc669a

Please sign in to comment.