Skip to content

Commit

Permalink
Merge pull request #43 from bedus-creation/image-link-fix
Browse files Browse the repository at this point in the history
fix: image link fix
  • Loading branch information
bedus-creation committed May 4, 2023
2 parents ac54eb1 + d489edd commit 8952609
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 51 deletions.
5 changes: 0 additions & 5 deletions app/Application/Admin/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public function store(ArticleStoreRequest $articleStoreRequest): RedirectRespons
return redirect()->back()->with('success', 'Article has been created.');
}

public function show(Article $article)
{
return view('admin.articles.show', compact('article'));
}

/**
* @param Request $request
* @param $id
Expand Down
15 changes: 11 additions & 4 deletions app/Domain/CMS/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
namespace App\Domain\CMS\Models;

use Aammui\LaravelMedia\Enum\Responsive;
use Aammui\LaravelMedia\Models\Media;
use Aammui\LaravelMedia\Traits\HasMedia;
use Aammui\LaravelTaggable\Traits\HasCategory;
use Aammui\LaravelTaggable\Traits\HasTag;
use App\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

class Post extends Model
{
use HasCategory, HasTag, HasMedia;
use HasCategory, HasTag;
use HasMedia;

protected $table = 'posts';

Expand All @@ -30,10 +33,14 @@ public function link(): string
return url('posts/' . $this->id . '/' . Str::slug($this->title));
}

public function getCoverAttribute()
public function cover($size =Responsive::SM): string
{
return optional(optional($this->fromCollection('cover')->getMedia())->first())->link(Responsive::LG)
?? "/assets/img/logo.png";
/** @var Media $media */
$media = $this->fromCollection('cover')->getMedia()->first();
$link = json_decode($media?->in_json, true);
$path = $link['url']['lg'] ?? "/assets/img/logo.png";

return Storage::disk($media->disk)->url($path);
}

public function user(): BelongsTo
Expand Down
37 changes: 0 additions & 37 deletions app/Models/Laradash/Media.php

This file was deleted.

2 changes: 0 additions & 2 deletions bin/release.sh

This file was deleted.

8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"release": [
"@php artisan ziggy:generate --env=live",
"yarn build"
],
"dev": [
"@php artisan ziggy:generate",
"yarn dev"
]
},
"extra": {
Expand Down
4 changes: 2 additions & 2 deletions resources/views/front/pages/post.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<section class="py-5 my-4 ">
<div class="container mx-auto px-6 lg:px-0">
<div class="mx-auto md:w-3/5">
<a href="{{$post->cover ?? getImage()}}">
<img src="{{$post->cover ?? getImage()}}" class="img-fluid w-full rounded-lg"
<a href="{{$post->cover('lg') ?? getImage()}}">
<img src="{{$post->cover('lg') ?? getImage()}}" class="img-fluid w-full rounded-lg"
alt="{{$post->title}}">
</a>
<div class="py-6">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/front/pages/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@foreach($posts as $item)
<div class="w-full lg:flex mb-3">
<div class="h-48 lg:h-auto lg:w-48 flex-none bg-cover bg-center rounded-t-lg lg:rounded-t-none lg:rounded-l-lg text-center overflow-hidden"
style="background-image: url('{{$item->cover ?? getImage()}}')" title="Woman holding a mug">
style="background-image: url('{{$item->cover('sm') ?? getImage()}}')" title="Woman holding a mug">
</div>
<div
class="bg-white w-full rounded-b-lg lg:rounded-b-none lg:rounded-r-lg p-4 flex flex-col justify-between leading-normal">
Expand Down

0 comments on commit 8952609

Please sign in to comment.