This commit is contained in:
f4ilji
2024-10-28 12:57:16 +05:00
parent e4678fc0d2
commit 6d516d1750
233 changed files with 6312 additions and 1314 deletions
@@ -6,10 +6,14 @@ use App\Enums\FormEducation;
use App\Http\Resources\AdditionalEducationCategoryPreviewResource;
use App\Http\Resources\AdditionalEducationCategoryResource;
use App\Http\Resources\AdditionalEducationResource;
use App\Http\Resources\ClientBreadcrumbPage;
use App\Http\Resources\ClientBreadcrumbSection;
use App\Http\Resources\ClientBreadcrumbSubSection;
use App\Http\Resources\DirectionAdditionalEducationResource;
use App\Models\AdditionalEducation;
use App\Models\AdditionalEducationCategory;
use App\Models\DirectionAdditionalEducation;
use App\Models\Page;
use Illuminate\Http\Request;
use Inertia\Inertia;
@@ -85,19 +89,51 @@ class ClientAdditionalEducationController extends Controller
'content' => $categoriesContent,
],
];
$routeUrl = route('client.additionalEducation.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$breadcrumbs = null;
}
return Inertia::render('Client/Additional-educations/Index',
compact(
'directionAdditionalEducations',
'additionalEducations',
'filters',
'forms_education',
'categories'
'categories',
'breadcrumbs'
));
}
public function show(string $slug)
{
$additionalEducation = new AdditionalEducationResource(AdditionalEducation::query()->with('category.direction')->where('slug', $slug)->first());
return Inertia::render('Client/Additional-educations/Show', compact('additionalEducation'));
$routeUrl = route('client.additionalEducation.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$breadcrumbs = null;
}
return Inertia::render('Client/Additional-educations/Show', compact('additionalEducation', 'breadcrumbs'));
}
}
+37 -2
View File
@@ -2,12 +2,16 @@
namespace App\Http\Controllers;
use App\Http\Resources\ClientBreadcrumbPage;
use App\Http\Resources\ClientBreadcrumbSection;
use App\Http\Resources\ClientBreadcrumbSubSection;
use App\Http\Resources\ClientEventCategoryResource;
use App\Http\Resources\ClientEventFullResource;
use App\Http\Resources\ClientEventResource;
use App\Http\Resources\ClientNavigationResource;
use App\Models\Event;
use App\Models\EventCategory;
use App\Models\Page;
use Carbon\Carbon;
use DateTime;
use Illuminate\Http\Request;
@@ -24,13 +28,44 @@ class ClientEventController extends Controller
$events = $this->getEvents($currentDate);
$categories = ClientEventCategoryResource::collection(EventCategory::has('events')->get());
return Inertia::render('Client/Events/Index', compact('eventDates', 'events', 'currentDate', 'filters', 'categories'));
$routeUrl = route('client.event.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$breadcrumbs = null;
}
return Inertia::render('Client/Events/Index', compact('eventDates', 'events', 'currentDate', 'filters', 'categories', 'breadcrumbs'));
}
public function show(string $slug)
{
$event = new ClientEventFullResource(Event::where('slug', '=', $slug)->with('category')->first());
return Inertia::render('Client/Events/Show', compact('event'));
$routeUrl = route('client.event.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$breadcrumbs = null;
}
return Inertia::render('Client/Events/Show', compact('event', 'breadcrumbs'));
}
private function getCurrentDate(Request $request): array
+40 -3
View File
@@ -3,15 +3,21 @@
namespace App\Http\Controllers;
use App\Http\Resources\CategoryResource;
use App\Http\Resources\ClientBreadcrumbPage;
use App\Http\Resources\ClientBreadcrumbSection;
use App\Http\Resources\ClientBreadcrumbSubSection;
use App\Http\Resources\ClientNavigationResource;
use App\Http\Resources\ClientPostListResource;
use App\Http\Resources\ClientTagResource;
use App\Http\Resources\MainSectionResource;
use App\Http\Resources\PageResource;
use App\Http\Resources\PostResource;
use App\Models\Category;
use App\Models\MainSection;
use App\Models\Page;
use App\Models\Post;
use App\Models\Tag;
use Carbon\Carbon;
use Doctrine\DBAL\Schema\Column;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -33,6 +39,7 @@ class ClientPostController extends Controller
->with('category')
->select('title', 'slug', 'authors', 'category_id', 'preview', 'search_data', 'created_at')
->where('status', '=', 'published')
->where('publish_at', '<', Carbon::now())
->when(request()->input('search'), function ($query, $search) {
$query->whereRaw('LOWER(title) like ?', ["%".strtolower($search)."%"]);
})
@@ -100,13 +107,43 @@ class ClientPostController extends Controller
],
];
return Inertia::render('Client/Posts/Index', compact('filters', 'posts', 'categories', 'tags'));
$routeUrl = route('client.post.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$breadcrumbs = null;
}
return Inertia::render('Client/Posts/Index', compact('filters', 'posts', 'categories', 'tags', 'breadcrumbs'));
}
public function show(Request $request, $slug)
{
$post = new PostResource(Post::where('slug', $slug)->firstOrFail());
return Inertia::render('Client/Posts/Show', compact('post'));
$post = new PostResource(Post::where('slug', $slug)->where('publish_at', '<', Carbon::now())->firstOrFail());
$routeUrl = route('client.post.index');
$path = ltrim(parse_url($routeUrl, PHP_URL_PATH), '/');
$page = Page::where('path', '=', $path)->with('section.pages.section', 'section.mainSection')->first();
if (isset($page->section)) {
$breadcrumbs = [
'mainSection' => new ClientBreadcrumbSection($page->section->mainSection),
'subSection' => new ClientBreadcrumbSubSection($page->section),
'page' => new ClientBreadcrumbPage($page),
];
} else {
$subSectionPages = null;
$breadcrumbs = null;
}
return Inertia::render('Client/Posts/Show', compact('post', 'breadcrumbs'));
}
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers;
use App\Http\Resources\ClientPageReferenceListResource;
use App\Models\PageReferenceList;
use Illuminate\Http\Request;
class ClientWidgetPageReferenceListController extends Controller
{
public function show(string $slug)
{
return new ClientPageReferenceListResource(PageReferenceList::query()->where('slug', $slug)->first());
}
}
+3
View File
@@ -22,6 +22,8 @@ use App\Models\MainSection;
use App\Models\MainSlider;
use App\Models\Post;
use App\Services\Filament\Icon\ArrayToCollectionService;
use App\Services\Vicon\EducationalProgram\EducationalProgramService;
use Carbon\Carbon;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
@@ -63,6 +65,7 @@ class MainController extends Controller
$posts = PostThumbnailResource::collection(Post::query()
->select('title', 'slug', 'authors', 'preview_text', 'category_id', 'preview', 'search_data', 'created_at')
->with('category')
->where('publish_at', '<', Carbon::now())
->where('status', '=', PostStatus::PUBLISHED)
->orderBy('publish_at', 'desc')->limit(3)
->get());
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use Inertia\Inertia;
class VkAuthController extends Controller
{
}
+34 -16
View File
@@ -2,8 +2,16 @@
namespace App\Http\Controllers;
use App\Jobs\CreateVkPost;
use App\Services\VK\VkAuthService;
use App\Services\VK\VkService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Inertia\Inertia;
use Symfony\Component\Finder\Finder;
use VK\Client\VKApiClient;
use VK\OAuth\Scopes\VKOAuthUserScope;
use VK\OAuth\VKOAuth;
@@ -16,33 +24,43 @@ class VkPostController extends Controller
private VkService $vkService;
public function __construct()
{
$this->vkService = new VkService(new VKApiClient());
$this->wall_token = env('WALL_ACCESS_VK_TOKEN');
}
public function index()
{
$oauth = new VKOAuth();
$client_id = 52468445;
$redirect_uri = 'https://crawdad-fresh-bream.ngrok-free.app/';
$display = VKOAuthDisplay::PAGE;
$scope = array(VKOAuthUserScope::WALL, VKOAuthUserScope::PHOTOS);
$state = 'dJZ3N05uZc9jpcEgxD6y';
$groups_ids = array(227826614);
$browser_url = $oauth->getAuthorizeUrl(VKOAuthResponseType::TOKEN, $client_id, $redirect_uri, $display, $scope, $state, $groups_ids);
return redirect($browser_url);
}
public function wall()
{
return $this->vkService->createAlbum('Тестовый альбом');
dd($this->vkService->getPostById(39));
}
public function getImages()
{
// Укажите путь к директории
$directory = 'public/images';
// Получаем все файлы из директории
$files = Storage::files($directory);
// Фильтруем только изображения (например, jpg, png)
$images = array_filter($files, function ($file) {
return in_array(pathinfo($file, PATHINFO_EXTENSION), ['webp', 'jpeg', 'png', 'gif']);
});
// Формируем полный URL для каждого изображения
$imageUrls = array_map(function ($file) {
return url(Storage::url($file)); // Добавляем домен
}, $images);
return $imageUrls; // Возвращаем массив с полными URL изображений
}
}