prodV1 #2

Open
RomanGolienko wants to merge 309 commits from prodV1 into main
3 changed files with 22 additions and 14 deletions
Showing only changes of commit 66fdb9d7b0 - Show all commits

View File

@ -0,0 +1,18 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Str;
class SlugHelper
{
public static function get(array $validated): string
{
if ($validated['slug'] === null) {
$transliterationSlug = Str::slug($validated['name']);
$randomNumber = random_int(100, 999);
return "{$transliterationSlug}-{$randomNumber}";
}
return $validated['slug'];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\admin\Catalog\Direction; namespace App\Http\Controllers\admin\Catalog\Direction;
use App\Helpers\SlugHelper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\Direction\StoreDirectionProfileRequest; use App\Http\Requests\admin\Catalog\Direction\StoreDirectionProfileRequest;
use App\Http\Requests\admin\Catalog\Direction\UpdateDirectionProfileRequest; use App\Http\Requests\admin\Catalog\Direction\UpdateDirectionProfileRequest;
@ -31,13 +32,7 @@ class DirectionProfileController extends Controller
{ {
$validated = $request->validated(); $validated = $request->validated();
if ($validated['slug'] === null) { $slug = SlugHelper::get($validated);
$transliterationSlug = Str::slug($validated['name']);
$randomNumber = random_int(100, 999);
$slug = "{$transliterationSlug}-{$randomNumber}";
} else {
$slug = $validated['slug'];
}
$directionProfile = new DirectionProfile(); $directionProfile = new DirectionProfile();
$directionProfile->name = $validated['name']; $directionProfile->name = $validated['name'];

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers\admin\Catalog; namespace App\Http\Controllers\admin\Catalog;
use App\Helpers\SlugHelper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreFacultyRequest; use App\Http\Requests\admin\Catalog\StoreFacultyRequest;
use App\Http\Requests\admin\Catalog\UpdateFacultyRequest; use App\Http\Requests\admin\Catalog\UpdateFacultyRequest;
@ -33,13 +34,7 @@ class FacultyController extends Controller
{ {
$validated = $request->validated(); $validated = $request->validated();
if ($validated['slug'] === null) { $slug = SlugHelper::get($validated);
$transliterationSlug = Str::slug($validated['name']);
$randomNumber = random_int(100, 999);
$slug = "{$transliterationSlug}-{$randomNumber}";
} else {
$slug = $validated['slug'];
}
$faculty = new Faculty(); $faculty = new Faculty();
$faculty->name = $validated['name']; $faculty->name = $validated['name'];