Skip to content

Commit 0cc669a

Browse files
committed
few more fixes
1 parent 88c8d40 commit 0cc669a

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
@isset($smartAd)
22
<div class="smart-banner-temp" banner-slug="{{$smartAd->slug}}">
3-
{!! $smartAd->body !!}
3+
@if($smartAd->adType == 'HTML')
4+
{!! $smartAd->body !!}
5+
@elseif($smartAd->adType == 'IMAGE')
6+
<a href="{{($smartAd->imageUrl ? $smartAd->imageUrl : '#')}}" target="_blank">
7+
<img src="{{asset('storage/'.$smartAd->image)}}" alt="{{$smartAd->imageAlt}}" />
8+
</a>
9+
@endif
410
</div>
511
@endisset

src/Http/Controllers/SmartAdManagerController.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,24 @@ public function edit(SmartAd $smartAd){
5454

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

57-
if(isset($request->image)){
58-
$imagePath = $request->file('image')->store('image', 'public');
59-
$smartAd->image = $imagePath;
60-
}
61-
6257
$smartAd->name = $request->name;
63-
$smartAd->body = isset($request->body) ? $request->body : null;
64-
$smartAd->imageUrl = isset($request->imageUrl) ? $request->imageUrl : null;
65-
$smartAd->imageAlt = isset($request->imageAlt) ? $request->imageAlt : null;
6658
$smartAd->placements = $request->placements;
59+
if($request->adType == 'HTML'){
60+
$smartAd->image = null;
61+
$smartAd->imageUrl = null;
62+
$smartAd->imageAlt = null;
63+
$smartAd->body = $request->body;
64+
}elseif($request->adType == 'IMAGE'){
65+
if(isset($request->image)){
66+
$imagePath = $request->file('image')->store('image', 'public');
67+
$smartAd->image = $imagePath;
68+
}
69+
70+
$smartAd->imageUrl = isset($request->imageUrl) ? $request->imageUrl : null;
71+
$smartAd->imageAlt = isset($request->imageAlt) ? $request->imageAlt : null;
72+
}
73+
$smartAd->adType = $request->adType;
74+
6775
$smartAd->save();
6876
return redirect("/smart-ad-manager/ads/{$smartAd->id}")->with(['message' => 'Ad Edited', 'color' => 'green']);
6977
}

0 commit comments

Comments
 (0)