<commit_before><?php

namespace Orchid\Foundation\Http\Controllers\Posts;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Orchid\Foundation\Core\Models\Post;
use Orchid\Foundation\Facades\Alert;
use Orchid\Foundation\Http\Controllers\Controller;

class PostController extends Controller
{
    /**
     * @var
     */
    public $locales;

    /**
     * PostController constructor.
     */
    public function __construct()
    {
        $this->locales = collect(config('content.locales'));
    }

    /**
     * @param Post $post
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(Post $post)
    {
        return view('dashboard::container.posts.main', $post->getTypeObject()->generateGrid());
    }

    /**
     * @param $post
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function create($post)
    {
        $type = $post->getTypeObject();

        return view('dashboard::container.posts.create', [
            'type'    => $type,
            'locales' => $this->locales->where('required', true),
        ]);
    }

    public function show($test = null, $test2 = null)
    {
        dd($test, $test2);
    }

    /**
     * @param Request $request
     * @param Post    $post
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(Request $request, Post $post)
    {
        $this->validate($request, $post->getTypeObject()->rules());

        $post->fill($request->all());
        $post->type = $post->getTypeObject()->slug;
        $post->user_id = Auth::user()->id;
        $post->slug = Str::slug($request->get('content')[config('app.locale')][$post->getTypeObject()->slugFields]);
        $post->publish_at = (is_null($request->get('publish'))) ? null : Carbon::parse($request->get('publish'));

        $Slugs = $post->where('slug', $post->slug)->count();
        if ($Slugs != 0) {
            $post->slug = $post->slug.'-'.($Slugs + 1);
        }
<commit_msg>Фильтр для уникальных значений<commit_after><?php

namespace Orchid\Foundation\Http\Controllers\Posts;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Orchid\Foundation\Core\Models\Post;
use Orchid\Foundation\Facades\Alert;
use Orchid\Foundation\Http\Controllers\Controller;

class PostController extends Controller
{
    /**
     * @var
     */
    public $locales;

    /**
     * PostController constructor.
     */
    public function __construct()
    {
        $this->locales = collect(config('content.locales'));
    }

    /**
     * @param Post $post
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(Post $post)
    {
        return view('dashboard::container.posts.main', $post->getTypeObject()->generateGrid());
    }

    /**
     * @param $post
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function create($post)
    {
        $type = $post->getTypeObject();

        return view('dashboard::container.posts.create', [
            'type'    => $type,
            'locales' => $this->locales->where('required', true),
        ]);
    }

    public function show($test = null, $test2 = null)
    {
        dd($test, $test2);
    }

    /**
     * @param Request $request
     * @param Post    $post
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function store(Request $request, Post $post)
    {
        $this->validate($request, $post->getTypeObject()->rules());

        $post->fill($request->all());
        $post->type = $post->getTypeObject()->slug;
        $post->user_id = Auth::user()->id;
        $post->slug = Str::slug($request->get('content')[config('app.locale')][$post->getTypeObject()->slugFields]);
        $post->publish_at = (is_null($request->get('publish'))) ? null : Carbon::parse($request->get('publish'));

        $Slugs = $post->where('slug', $post->slug)->count();
        if ($Slugs != 0) {
            $post->slug = $post->slug.'-'.($Slugs + $Slugs);
        }

{'fraction_non_alphanumeric': 0.17553444180522565, 'fraction_numerical': 0.00166270783847981, 'mean_word_length': 2.611492281303602, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1368473', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1318, 'n_words': 209}