-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip activities & activity page * update activity on activities page, fix bubbles * remove subtitle from activities, fix navigation elements' hover, update home controller, add remembering tags when changed pages in pagination, update activity card * lang * margins * fixes * mobile design * set bubbles visibility * mobile fix * rwd * activities mobile tags * cr changes * migration * change
- Loading branch information
1 parent
6e84754
commit 4825dc7
Showing
44 changed files
with
704 additions
and
614 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Website\Actions; | ||
|
||
use Blumilk\Website\Models\News; | ||
|
||
class RemoveTagFromNewsAction | ||
{ | ||
public function execute(int $tagId): void | ||
{ | ||
News::query()->whereJsonContains("tags", $tagId)->get() | ||
->each(function (News $news) use ($tagId): void { | ||
$news->tags = array_values(array_diff($news->tags, [$tagId])); | ||
$news->save(); | ||
}); | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
app/Filament/Resources/ActivityResource/Pages/CreateActivity.php
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
app/Filament/Resources/ActivityResource/Pages/ListActivities.php
This file was deleted.
Oops, something went wrong.
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
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
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Website\Filament\Resources\NewsResource\Pages; | ||
|
||
use Blumilk\Website\Filament\Resources\NewsResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateNews extends CreateRecord | ||
{ | ||
protected static string $resource = NewsResource::class; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Website\Filament\Resources\NewsResource\Pages; | ||
|
||
use Blumilk\Website\Filament\Resources\BaseResource\Pages\BaseListRecord; | ||
use Blumilk\Website\Filament\Resources\NewsResource; | ||
|
||
class ListNews extends BaseListRecord | ||
{ | ||
protected static string $resource = NewsResource::class; | ||
} |
This file was deleted.
Oops, something went wrong.
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,90 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Blumilk\Website\Http\Controllers; | ||
|
||
use Blumilk\Website\Http\Resources\NewsResource; | ||
use Blumilk\Website\Http\Resources\TagResource; | ||
use Blumilk\Website\Models\News; | ||
use Blumilk\Website\Models\Tag; | ||
use Illuminate\Contracts\View\Factory; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Http\Request; | ||
|
||
class NewsController extends Controller | ||
{ | ||
public function index(Request $request, Factory $factory): View | ||
{ | ||
$tagFromQuery = $request->get("tag"); | ||
$tag = $tagFromQuery | ||
? Tag::query() | ||
->where("title->pl", "LIKE", $tagFromQuery) | ||
->orWhere("title->en", "LIKE", $tagFromQuery) | ||
->firstOrFail() | ||
: null; | ||
$allNewsCount = News::query() | ||
->where("published", true) | ||
->count(); | ||
$news = News::query() | ||
->where("published", true) | ||
->when($tag, fn($query, $tag) => $query->whereJsonContains("tags", $tag->id)) | ||
->latest("published_at") | ||
->paginate(7) | ||
->appends(["tag" => $tagFromQuery]); | ||
$tags = Tag::query() | ||
->where("is_primary", true) | ||
->get(); | ||
|
||
$tagsNewsCount = []; | ||
|
||
foreach ($tags as $singleTag) { | ||
$tagsNewsCount[$singleTag->title] = $singleTag->newsCount(); | ||
} | ||
|
||
$filteredTags = $tags->filter(fn($tag): bool => $tagsNewsCount[$tag->title] > 0); | ||
|
||
return $factory->make("news") | ||
->with("news", NewsResource::collection($news)) | ||
->with("tags", $filteredTags->pluck("title")) | ||
->with("tagsNewsCount", $tagsNewsCount) | ||
->with("selectedTag", $tag?->title) | ||
->with("allNewsCount", $allNewsCount); | ||
} | ||
|
||
public function get(Request $request, Factory $factory, string $slug): View | ||
{ | ||
$urlPath = $request->getRequestUri(); | ||
$articleUrl = config("app.url") . $urlPath; | ||
|
||
$news = News::query()->where("slug", $slug)->firstOrFail(); | ||
$newsTags = $news->getRelatedTagModels(); | ||
|
||
$nextNews = News::query()->where("id", ">", $news->id)->where("published", true)->orderBy("id", "asc")->take(2)->get(); | ||
$previousNews = News::query()->where("id", "<", $news->id)->where("published", true)->orderBy("id", "desc")->take(2)->get(); | ||
|
||
if (!$previousNews->first()) { | ||
$recommendedNews = $nextNews; | ||
} elseif (!$nextNews->first()) { | ||
$recommendedNews = $previousNews; | ||
} else { | ||
$recommendedNews = [$previousNews->first(), $nextNews->first()]; | ||
} | ||
|
||
$tagsNewsCount = []; | ||
|
||
foreach ($newsTags as $singleTag) { | ||
$tagsNewsCount[$singleTag->title] = $singleTag->newsCount(); | ||
} | ||
|
||
$news = new NewsResource($news); | ||
|
||
return $factory->make("single-news") | ||
->with("news", $news->resolve()) | ||
->with("tags", TagResource::collection($newsTags->where("as_person", false))->resolve()) | ||
->with("tagsNewsCount", $tagsNewsCount) | ||
->with("peopleTags", TagResource::collection($newsTags->where("as_person", true))->resolve()) | ||
->with("recommendedNews", NewsResource::collection($recommendedNews)->resolve()) | ||
->with("articleUrl", $articleUrl); | ||
} | ||
} |
Oops, something went wrong.