hsntngr

hsntngr

Member Since 1 Year Ago

Experience Points 3,650
Experience
Level
Lessons Completed 7
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

06 Jan
1 week ago

hsntngr left a reply on Laravel Dosen't Redirect Request

The problem is not about specify a prefix to a route. I already setup the locale and fallback languages by request region. And I also don't want to present my webpages without lang parameter, it not good for seo (as I know).

If user dont use links and buttons and type url manually he may forgot the lang parameters. So url will return 404 page instead of target page. When that happened I want to catch that url, add the lang parameter and redirect to the correct page..

Actually I may found a solution couple minutes ago. I moved above code into Exceptions/Handler.php and it seems work

public function render($request, Exception $exception)
    {
        if($exception instanceof NotFoundHttpException){
            $langParameter = $request->segment(1);
            $supportedLanguages = config("translate.locales");
            if (strlen($langParameter) == 2) {
                $locale = $langParameter;
                if (in_array($locale, $supportedLanguages))
                    app()->setLocale($locale);
                else {
                    app()->setLocale(config("en"));
                }
            } else {
                $locale = in_array($request->getPreferredLanguage(), $supportedLanguages) ?
                    $request->getPreferredLanguage() : config("translate.locale");
                $redirectTo = $locale . $request->getPathInfo();
                app('session')->reflash();
                return redirect($redirectTo, 302, ['Vary' => 'Accept-Language']);
            }
        }
        return parent::render($request, $exception);
    }

hsntngr left a reply on Laravel Dosen't Redirect Request

@sergiu17 it was but I tihs time I was not able to redirect request so I moved to AppServiceProvider (I know it's very bad practise I couldn't see any solution)

There are two types of routes, localized and non-localized

non localized routes

Route::get("sitemap.xml", [
    "as" => "sitemap",
    "uses" => "[email protected]"
]);

// /sitemap.xml

and localized routes

// in RouteServiceProvider 
Route::group([
       'middleware' => ["web","translate"],
       'namespace' => $this->namespace,
  ], function ($router) {
       require base_path('routes/games.php');
});

// in route file
Route::group([
    "prefix" => app()->getLocale();
], function () {
Route::get("blog","[email protected]");
});

@snapey well it was a global middleware at the first place, but I realized it's not able to redirect request if they are not have lang parameter. Because localized routes has dynamic lang parameter as you can see above, if lang parameters doesn't exist it throws route not found error and returns 404. So I moved to above code block to AppServiceProvider to check request whether request has lang parameter
05 Jan
1 week ago

hsntngr left a reply on Laravel Dosen't Redirect Request

@sergiu17 when I move to this code a middleware and there is url without lang parameter, it throws route not found error and gives 404 error.. So request can't reach the middleware

hsntngr started a new conversation Laravel Dosen't Redirect Request

Make a redirection in AppServiceProvider

I'm trying to do redirection in AppServiceProvider. if url doesn't have any lang parameter, I want to add lang parameter and redirect request to updated url.. But nothing happens.

public function boot(Request $request)
    {
        if (!$this->doNotLocalize($request)) {
            $langParameter = $request->segment(1);
            $supportedLanguages = config("translate.locales");
            // Dump the first element (empty string) as getPathInfo() always returns a leading slash
            if (strlen($langParameter) == 2) {
                $locale = $langParameter;
                if (in_array($locale, $supportedLanguages))
                    $this->app->setLocale($locale);
                else {
                    $this->app->setLocale(config("en"));
                }
            } else {
                $locale = in_array($request->getPreferredLanguage(), $supportedLanguages) ?
                    $request->getPreferredLanguage() : config("translate.locale");
                $redirectTo = $locale . $request->getPathInfo();
                // Save any flashed data for redirect
                app('session')->reflash();
                redirect($redirectTo, 302, ['Vary' => 'Accept-Language']);
            }
        }
   }

Am I doing wrong or are we not able to redirect requests in service providers ?

29 Dec
2 weeks ago

hsntngr started a new conversation Laravel Route Not Found Error While Using Global Route Prefix

I'm using laravel 5..7 and having some trouble on multilingual website... I have global route prefix for adding seo purposes. (adding lang parameters like en,tr to url)

 Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => in_array(Request::segment(1), $this->noLangPrefix) ? "" : Request::segment(1)
        ]...

it actually works pretty well with below Language middleware..


public function handle($request, Closure $next)
    {
        $langSegment = $request->segment(1);

        // go ahead if is admin panel or sitemap
        if ($langSegment == "admin")
            return $next($request);

        if ($langSegment == "sitemap.xml")
            return $next($request);

        // if is homepage 
        if (is_null($langSegment)) {
            app()->setLocale($request->getPreferredLanguage((config("app.locales"))));
            return $next($request);
        }

        if (strlen($langSegment) == 2)
            return $next($request);

        return redirect(url(config("app.locale") . "/" . implode($request->segments())));
    }

When i say, "app.test/blog" it redirects me to "app.test/tr/blog"

But if I say "app.test/blog/sample-blog-spot" it gives me Symfony\Component\HttpKernel\Exception\NotFoundHttpException

Why I'm getting this error ? Because it cant fine route or something and how can I fix it ?

05 Nov
2 months ago

hsntngr started a new conversation Laravel Eager Loading Doesn't Work While Using View::composer() Method

I'm trying to get some of current post for sidebar. So I create a composer method inside of [email protected] method.

I'm able to get products and also see to media relation in relations segments. But it seems empty. (But all products have 3 image minimum and I can see them when I write this query at controller)

\View::composer("frontend._partials._sidebar", function ($view) {
            $new_products = Product::select("title", "slug")
                ->with("media")
                ->orderBy("id", "desc")
                ->take(5)
                ->get();

            $view->with("new_products", $new_products);
        });

#relations: array:1 [▼ "media" => Collection {#930 ▼ #items: [] } ]

How do I fix this ?

02 Nov
2 months ago

hsntngr left a reply on User Fields Seem Empty When The User Is Has Been Registered

I have no idea what is happening. But I guess it's not about adding extra columns Because It happened after updating to 5.7 from 5.6

Should I create bug report on github ?

hsntngr left a reply on User Fields Seem Empty When The User Is Has Been Registered

@tykus they are null in database record.

You can see database record clearly in this ss (https://imgur.com/a/nNwmkTp)

hsntngr left a reply on Ser Fields Seem Empty When The User Is Has Been Registered

@tykus the role column has default value, so no need to specify field I guess ?

hsntngr started a new conversation Ser Fields Seem Empty When The User Is Has Been Registered

I added couple new columns to users table like role, suspended_at and banned_at. And then added them as fillable.

But when new user registered, fields seems empty (except id,created_at and updated_at).

Here is migration file

Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string("username", 20)->unique()->index();
        $table->string('email')->unique();
        $table->string('password');
        $table->string("role",15)->default("newbie");
        $table->rememberToken();
        $table->timestamps();
        $table->dateTime("suspended_at")->nullable();
        $table->dateTime("banned_at")->nullable();
    });

User model

protected $fillable = [
        'name', 'email', 'password', "username", "role", "suspended_at", "banned_at"
    ];

**a small demo from users table. **

+----+------+----------+-------+----------+------+
| id | name | username | email | password | role |
+----+------+----------+-------+----------+------+
|  4 |      |          |       |          |      |
+----+------+----------+-------+----------+------+

RegisterController

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        "username" => $data["username"],
        'password' => Hash::make($data['password'])
    ]);
}
31 Oct
2 months ago

hsntngr started a new conversation How To Get All Values From Session Which Start With Certain Key

As the title, I want to get all values from session which start with certain value.

For example, I'm counting post views in my project and I'm storing them on session. Then I want to reach all stored viewed values on session..

Session::put("views.".$post->id);

How can I get all stored views ?

is there any way to do it something like below ?

Session::get("views.*");
26 Oct
2 months ago

hsntngr started a new conversation Laravel - Js Sections Of Different Blade Files Making Conflict

I have two blade file and both of them has js section. But in the browser, shows only comments js files not single. I need to use both js files.

Here are blade files in a nutshell

comments.blade

// php and html codes
@section("js")
 // js codes of comments blade
@endsection

single.blade

@extends("master")
@section("content")
 // html and php codes 
 @include("comments")
@endsection
@section("js")
 // js codes of single blade
@endsection

Why there are conflict between two blade file ? And how do I fix it ?

01 Sep
4 months ago

hsntngr left a reply on Disable Laravel Error Reporting

did you clear cache after that ? php artisan config:clear

hsntngr left a reply on Binding Many Singleton Is Harmful ?

@topvillas then how about bind() method ? is it similar with singleton ? If I use bind method, is laravel create instance when I need it ?

hsntngr started a new conversation Binding Many Singleton Is Harmful ?

I'm trying to do repository pattern and binding all repositories in RepositoryServiceProvider. When a http request started, do all singleton binding again and again ? And is it harmful, is slow down the application ?

 public function register()
    {

        $this->app->singleton(IGameRepository::class,function ($app){
          return new GameCacheRepository((new GameEloquentRepository((new Game))));
        });

        $this->app->singleton(IUserRepository::class,function ($app){
            return new UserCacheRepository((new UserEloquentRepository((new User))));
        });

        $this->app->singleton(IArticleRepository::class,function ($app){
            return new ArticleCacheRepository((new ArticleEloquentRepository((new Article))));
        });
...
16 Aug
5 months ago

hsntngr started a new conversation How Can I Create Query About Relations And Non Relations Tables ?

Well, it's hard to complain at the title, sorry for such a ridiculous title..

I have many tables named suspended_users, drafts, post_translations, products, reviews and specs

When I get the suspended user also I want to get related product about him. Suspect model have relation with Draft, Draft model have relation with PostTranslation.

I can easly acces the post_translations table, there is no problem with that. But I can't access the products, reviews or specs table from post_translations. How can I make it ?

Draft table for the suspicious reviews or product description (users are allowed to change those descriptions) If some users try to delete contents or try to spamming, I want to store them their posts as a draft.

So... Do you have any advice to make that ? I try with joins, relation load or with methods but didin't work yet..

Here are migrates..

Schema::create('suspended_users', function (Blueprint $table) {
            $table->increments('id');
            $table->integer("user_id")->unsigned();
            $table->integer("article_id")->unsigned();
            $table->timestamps();

            $table->foreign("user_id")->references("id")->on("users")->onDelete("cascade");
            $table->foreign("article_id")->references("id")->on("post_translations")->onDelete("cascade");
        });

Schema::create('drafts', function (Blueprint $table) {
            $table->increments('id');

            $table->integer("user_id")->unsigned()->nullable();
            $table->integer("article_id")->unsigned()->index();
            $table->longText("content");
            $table->timestamps();

            $table->foreign("article_id")->references("id")->on("post_translations")->onDelete("cascade");
            $table->foreign("user_id")->references("id")->on("users")->onDelete("cascade");
        });

Schema::create('post_translations', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('post_id')->unsigned(); // means product or review id
            $table->integer("user_id")->unsigned();

            $table->string("post_type",20); // means table of post (like reviews)
            $table->string("post_status",20);
            $table->string('locale')->index();

            $table->longText('content')->nullable();
        });

Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string("title");
            $table->string("slug");
            $table->dateTime("release_date");
            $table->timestamps();
        });
14 Aug
5 months ago

hsntngr started a new conversation Is Cache Class Serialize The Collection When It Stored ?

I'm trying to cache my posts first time in laravel and I wanna ask something. Is laravel cache class serialize the collectin ? Or we have to serialize returning collection ?

$post_article = \Cache::remember("posts.$post->id." . app()->getLocale(), $minutes = "720", function () use ($post) {
            if (\Cache::has("posts.$post->id"))
                return \Cache::get("posts.$post->id." . app()->getLocale());
            else
                return PostTranslation::getTransArticle($post->id, "review", "published")
                    ?? trans("posts.noDataAboutPost");
        });
``

10 Aug
5 months ago

hsntngr left a reply on About Route Parameters

@cmdobueno yeah me too, I didin't use it before but there are multilingual part in url, so url should be like..

"{slug]"."-".trans("product.name")

I checked out the document but got nothing :/

hsntngr started a new conversation About Route Parameters

Can I use that for defining a parameter ?

Route::get("{slug}"."-product"...)

I tried that but it gives me page not found error. it doesn't match with route

hsntngr started a new conversation Laravel Page Not Found Error While Using Global Route Prefix

I want to build multilingual website with laravel and I want to make urls seo friendly.

So I added prefix to whole routes language segment using RouteServiceProvider

Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => $this->app->getLocale()
        ], function ($router) {...);

Are we should any parameter for the language ? Because I didin't use any parameter for routes..

Route::group(["prefix"=>trans("routes.admin")],function (){
    Route::get("/",["as"=>"admin.index","uses"=>"[email protected]"]);
});

I research about it on stackoverflow, laravel.com but I couldn't find anything useful.

How do I can fix this error ? Any help would be appreciated.

09 Aug
5 months ago

hsntngr left a reply on Laravel Can't Find Other Language Files

@click Finally I find out, it was about directory permission.. thanks for your all help and patient

hsntngr left a reply on Laravel Can't Find Other Language Files

@click I checked out call trace with xdebug but still can't figure out..

hsntngr left a reply on Laravel Can't Find Other Language Files

@click I'm sorry, I didin't see to your last sentence..

hsntngr left a reply on Laravel Can't Find Other Language Files

@click works fine, it says "Hello!"

hsntngr left a reply on Laravel Can't Find Other Language Files

@click Yes I though that. So I reinstall laravel and tried with that no package, no custom codes. Just laravel and localization codes.. that didin't work too..

I cleared even route cache :D But didin't help too..

hsntngr left a reply on Laravel Can't Find Other Language Files

@Cronix

Well, there are no errors and I try to dump results like getLocale(), $request->segment(1) etc.. And didin't encounter with anything wrong.. everything seems work fine..

I used translation helpers, I tried with @trans, trans() and __()

hsntngr left a reply on Laravel Can't Find Other Language Files

@click it says "These credentials do not match our records."

hsntngr left a reply on Laravel Can't Find Other Language Files

@s4muel they're all in lang directory, I just forgot to type

hsntngr left a reply on Laravel Can't Find Other Lang Files ?

@s4muel I just forgot the type here, they're all in lang directory

hsntngr left a reply on Laravel Can't Find Other Language Files

@Procat I checked before. I said that dd(app()->getLocale()) in view and it returned "tr"...

hsntngr started a new conversation Laravel Can't Find Other Language Files

Laravel can't find other language files

My lang files under the resources folder.

--resources ----en +auth.php (etc..) ----tr +auth.php(etc..)

When I set locale language as tr, still shows english messages.

How do I fix this ?

hsntngr started a new conversation Laravel Can't Find Other Lang Files ?

Laravel can't find other language files

My lang files under the resources folder.

--resources ----en +auth.php (etc..) ----tr +auth.php(etc..)

When I set locale language as tr, still shows english messages.

How do I fix this ?

hsntngr started a new conversation Laravel Localization-translation Doesn't Work, Shows Only Default Language

I'm trying to build multilingual website with laravel but there is a problem with translation. It shows only default language. Even if I set the app locale language, laravel continue to shows default language

when I said app.test/ar/admin or `app.test/en/admin, routes and others works as well, I can reach the view, just trans message not work..

admin blade

<div class="row">
   <h1>{{trans('admin.welcome')}}</h1>
</div>

I tried with __('admin.welcome') but still same result..

app service provider;

public function boot(Request $request)
    {
        if (!session()->has("locale")) {
            session()->put("locale", $request->getPreferredLanguage(config("translatable.locales")));
        }
        app()->setLocale(session()->get("locale"));
    }

route service provider

 Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
            'prefix' => session()->get("locale"),
        ], function ($router) {...});

language middleware

public function handle(Request $request, Closure $next)
    {
        if (!in_array($request->segment(1), config('translatable.locales'))) {
            $segments = $request->segments();
            $segments = array_prepend($segments, app()->getLocale());
            return redirect()->to(implode('/', $segments));
        }

        return $next($request);
    }

so how can I fix this ? Any help would be appreciated.

27 Apr
8 months ago

hsntngr left a reply on Auth Facede Stop Working (?)

@rin4ik and @arukomp May I ask, is Auth facede avalaible at exceptions/handler.php and default error views like 404 ? Because in other places auth facede works as well

hsntngr started a new conversation Auth Facede Stop Working (?)

Auth face was working but suddenly it stop working. Did I make something wrong ?

For example;

@if(\Auth::user())
                <a href="{{route('admin.panel')}}">
                    <button class="btn btn-primary btn-sm mt-5 m-error_desc" style="color:white">
                        GO TO ADMIN PANEL
                    </button>
                </a>
           @else
                <a href="{{route('home.show')}}">
                    <button class="btn btn-primary btn-sm mt-5 m-error_desc" style="color:white">
                        GO TO HOMEPAGE
                    </button>
                </a>
@endif

This code doesn't work, it always return else result even if user logged in

hsntngr started a new conversation How To Redirect Users To Another Page With Session Messages While Error Occuring

I want to redirect users to admin page when any error occuring about the thujohn/twitter package. It throws Runtimeexception..

So I add couple code handler.php

public function render($request, Exception $exception)
{

    if ($exception instanceof \RuntimeException) {
        return redirect()->route('admin.panel')
            ->with('message', 'Please try again later..')
            ->with('message_type','warning');

    } else {
        return parent::render($request, $exception);
    }
}

But when I say that, it redirects user at all exceptions even at 404 errors or Trying to get property of non-object erros.. How can I fix this ? I want to redirect user for just relevant error

Or is there any way to do redirect user with condition like below.

if($exception->code == 436){
  // it says member has protected access. I can't use it code property outside of the exception class
      return redirect()->route('admin.panel')
            ->with('message', 'Specific error message')
            ->with('message_type','warning');

 }
22 Apr
8 months ago

hsntngr left a reply on How To Update The Record If It Exist Or If Not Create New Record

Yep I realized that :) thanks for your all helps @Cronix and @bwrice

hsntngr left a reply on How To Update The Record If It Exist Or If Not Create New Record

@jlrdw you are right.. I try to save with classic way it works. I create draft and update it succesfully. But I can't get it why updateOrCreate() method doesn't work. Everything seems normal ?

@Cronix here is what returns

<script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; (doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle); if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if (/\bsf-dump-compact\b/.test(oldClass)) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if (/\bsf-dump-expanded\b/.test(oldClass)) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } if (doc.createEvent && s.dispatchEvent) { var event = doc.createEvent('Event'); event.initEvent('sf-dump-expanded' === newClass ? 'sfbeforedumpexpand' : 'sfbeforedumpcollapse', true, false); s.dispatchEvent(event); } a.lastChild.innerHTML = arrow; s.className = s.className.replace(/\bsf-dump-(compact|expanded)\b/, newClass); if (recursive) { try { a = s.querySelectorAll('.'+oldClass); for (s = 0; s < a.length; ++s) { if (-1 == a[s].className.indexOf(newClass)) { a[s].className = newClass; a[s].previousSibling.lastChild.innerHTML = arrow; } } } catch (e) { } } return true; }; function collapse(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className; if (/\bsf-dump-expanded\b/.test(oldClass)) { toggle(a, recursive); return true; } return false; }; function expand(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className; if (/\bsf-dump-compact\b/.test(oldClass)) { toggle(a, recursive); return true; } return false; }; function collapseAll(root) { var a = root.querySelector('a.sf-dump-toggle'); if (a) { collapse(a, true); expand(a); return true; } return false; } function reveal(node) { var previous, parents = []; while ((node = node.parentNode || {}) && (previous = node.previousSibling) && 'A' === previous.tagName) { parents.push(previous); } if (0 !== parents.length) { parents.forEach(function (parent) { expand(parent); }); return true; } return false; } function highlight(root, activeNode, nodes) { resetHighlightedNodes(root); Array.from(nodes||[]).forEach(function (node) { if (!/\bsf-dump-highlight\b/.test(node.className)) { node.className = node.className + ' sf-dump-highlight'; } }); if (!/\bsf-dump-highlight-active\b/.test(activeNode.className)) { activeNode.className = activeNode.className + ' sf-dump-highlight-active'; } } function resetHighlightedNodes(root) { Array.from(root.querySelectorAll('.sf-dump-str, .sf-dump-key, .sf-dump-public, .sf-dump-protected, .sf-dump-private')).forEach(function (strNode) { strNode.className = strNode.className.replace(/\bsf-dump-highlight\b/, ''); strNode.className = strNode.className.replace(/\bsf-dump-highlight-active\b/, ''); }); } return function (root, x) { root = doc.getElementById(root); var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\')+')+', 'm'), options = {"maxDepth":1,"maxStringLength":160,"fileLinkFormat":"phpstorm:\/\/open?%f:%l"}, elt = root.getElementsByTagName('A'), len = elt.length, i = 0, s, h, t = []; while (i < len) t.push(elt[i++]); for (i in x) { options[i] = x[i]; } function a(e, f) { addEventListener(root, e, function (e) { if ('A' == e.target.tagName) { f(e.target, e); } else if ('A' == e.target.parentNode.tagName) { f(e.target.parentNode, e); } else if (e.target.nextElementSibling && 'A' == e.target.nextElementSibling.tagName) { f(e.target.nextElementSibling, e, true); } }); }; function isCtrlKey(e) { return e.ctrlKey || e.metaKey; } function xpathString(str) { var parts = str.match(/[^'"]+|['"]/g).map(function (part) { if ("'" == part) { return '"\'"'; } if ('"' == part) { return "'\"'"; } return "'" + part + "'"; }); return "concat(" + parts.join(",") + ", '')"; } addEventListener(root, 'mouseover', function (e) { if ('' != refStyle.innerHTML) { refStyle.innerHTML = ''; } }); a('mouseover', function (a, e, c) { if (c) { e.target.style.cursor = "pointer"; } else if (a = idRx.exec(a.className)) { try { refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}'; } catch (e) { } } }); a('click', function (a, e, c) { if (/\bsf-dump-toggle\b/.test(a.className)) { e.preventDefault(); if (!toggle(a, isCtrlKey(e))) { var r = doc.getElementById(a.getAttribute('href').substr(1)), s = r.previousSibling, f = r.parentNode, t = a.parentNode; t.replaceChild(r, a); f.replaceChild(a, s); t.insertBefore(s, r); f = f.firstChild.nodeValue.match(indentRx); t = t.firstChild.nodeValue.match(indentRx); if (f && t && f[0] !== t[0]) { r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\'), 'mg'), t[0]); } if (/\bsf-dump-compact\b/.test(r.className)) { toggle(s, isCtrlKey(e)); } } if (c) { } else if (doc.getSelection) { try { doc.getSelection().removeAllRanges(); } catch (e) { doc.getSelection().empty(); } } else { doc.selection.empty(); } } else if (/\bsf-dump-str-toggle\b/.test(a.className)) { e.preventDefault(); e = a.parentNode.parentNode; e.className = e.className.replace(/\bsf-dump-str-(expand|collapse)\b/, a.parentNode.className); } }); elt = root.getElementsByTagName('SAMP'); len = elt.length; i = 0; while (i < len) t.push(elt[i++]); len = t.length; for (i = 0; i < len; ++i) { elt = t[i]; if ('SAMP' == elt.tagName) { a = elt.previousSibling || {}; if ('A' != a.tagName) { a = doc.createElement('A'); a.className = 'sf-dump-ref'; elt.parentNode.insertBefore(a, elt); } else { a.innerHTML += ' '; } a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children'; a.innerHTML += '<span>&#9660;</span>'; a.className += ' sf-dump-toggle'; x = 1; if ('sf-dump' != elt.parentNode.className) { x += elt.parentNode.getAttribute('data-depth')/1; } elt.setAttribute('data-depth', x); var className = elt.className; elt.className = 'sf-dump-expanded'; if (className ? 'sf-dump-expanded' !== className : (x > options.maxDepth)) { toggle(a); } } else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) { a = a.substr(1); elt.className += ' '+a; if (/[\[{]$/.test(elt.previousSibling.nodeValue)) { a = a != elt.nextSibling.id && doc.getElementById(a); try { s = a.nextSibling; elt.appendChild(a); s.parentNode.insertBefore(a, s); if (/^[@#]/.test(elt.innerHTML)) { elt.innerHTML += ' <span>&#9654;</span>'; } else { elt.innerHTML = '<span>&#9654;</span>'; elt.className = 'sf-dump-ref'; } elt.className += ' sf-dump-toggle'; } catch (e) { if ('&' == elt.innerHTML.charAt(0)) { elt.innerHTML = '&hellip;'; elt.className = 'sf-dump-ref'; } } } } } if (doc.evaluate && Array.from && root.children.length > 1) { root.setAttribute('tabindex', 0); SearchState = function () { this.nodes = []; this.idx = 0; }; SearchState.prototype = { next: function () { if (this.isEmpty()) { return this.current(); } this.idx = this.idx < (this.nodes.length - 1) ? this.idx + 1 : 0; return this.current(); }, previous: function () { if (this.isEmpty()) { return this.current(); } this.idx = this.idx > 0 ? this.idx - 1 : (this.nodes.length - 1); return this.current(); }, isEmpty: function () { return 0 === this.count(); }, current: function () { if (this.isEmpty()) { return null; } return this.nodes[this.idx]; }, reset: function () { this.nodes = []; this.idx = 0; }, count: function () { return this.nodes.length; }, }; function showCurrent(state) { var currentNode = state.current(); if (currentNode) { reveal(currentNode); highlight(root, currentNode, state.nodes); } counter.textContent = (state.isEmpty() ? 0 : state.idx + 1) + ' of ' + state.count(); } var search = doc.createElement('div'); search.className = 'sf-dump-search-wrapper sf-dump-search-hidden'; search.innerHTML = ' <input type="text" class="sf-dump-search-input"> <span class="sf-dump-search-count">0 of 0<\/span> <button type="button" class="sf-dump-search-input-previous" tabindex="-1"> <svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"> <path d="M1683 1331l-166 165q-19 19-45 19t-45-19l-531-531-531 531q-19 19-45 19t-45-19l-166-165q-19-19-19-45.5t19-45.5l742-741q19-19 45-19t45 19l742 741q19 19 19 45.5t-19 45.5z"\/> <\/svg> <\/button> <button type="button" class="sf-dump-search-input-next" tabindex="-1"> <svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"> <path d="M1683 808l-742 741q-19 19-45 19t-45-19l-742-741q-19-19-19-45.5t19-45.5l166-165q19-19 45-19t45 19l531 531 531-531q19-19 45-19t45 19l166 165q19 19 19 45.5t-19 45.5z"\/> <\/svg> <\/button> '; root.insertBefore(search, root.firstChild); var state = new SearchState(); var searchInput = search.querySelector('.sf-dump-search-input'); var counter = search.querySelector('.sf-dump-search-count'); var searchInputTimer = 0; var previousSearchQuery = ''; addEventListener(searchInput, 'keyup', function (e) { var searchQuery = e.target.value; /* Don't perform anything if the pressed key didn't change the query */ if (searchQuery === previousSearchQuery) { return; } previousSearchQuery = searchQuery; clearTimeout(searchInputTimer); searchInputTimer = setTimeout(function () { state.reset(); collapseAll(root); resetHighlightedNodes(root); if ('' === searchQuery) { counter.textContent = '0 of 0'; return; } var xpathResult = doc.evaluate('//pre[@id="' + root.id + '"]//span[@class="sf-dump-str" or @class="sf-dump-key" or @class="sf-dump-public" or @class="sf-dump-protected" or @class="sf-dump-private"][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); while (node = xpathResult.iterateNext()) state.nodes.push(node); showCurrent(state); }, 400); }); Array.from(search.querySelectorAll('.sf-dump-search-input-next, .sf-dump-search-input-previous')).forEach(function (btn) { addEventListener(btn, 'click', function (e) { e.preventDefault(); -1 !== e.target.className.indexOf('next') ? state.next() : state.previous(); searchInput.focus(); collapseAll(root); showCurrent(state); }) }); addEventListener(root, 'keydown', function (e) { var isSearchActive = !/\bsf-dump-search-hidden\b/.test(search.className); if ((114 === e.keyCode && !isSearchActive) || (isCtrlKey(e) && 70 === e.keyCode)) { /* F3 or CMD/CTRL + F */ e.preventDefault(); search.className = search.className.replace(/\bsf-dump-search-hidden\b/, ''); searchInput.focus(); } else if (isSearchActive) { if (27 === e.keyCode) { /* ESC key */ search.className += ' sf-dump-search-hidden'; e.preventDefault(); resetHighlightedNodes(root); searchInput.value = ''; } else if ( (isCtrlKey(e) && 71 === e.keyCode) /* CMD/CTRL + G */ || 13 === e.keyCode /* Enter */ || 114 === e.keyCode /* F3 */ ) { e.preventDefault(); e.shiftKey ? state.previous() : state.next(); collapseAll(root); showCurrent(state); } } }); } if (0 >= options.maxStringLength) { return; } try { elt = root.querySelectorAll('.sf-dump-str'); len = elt.length; i = 0; t = []; while (i < len) t.push(elt[i++]); len = t.length; for (i = 0; i < len; ++i) { elt = t[i]; s = elt.innerText || elt.textContent; x = s.length - options.maxStringLength; if (0 < x) { h = elt.innerHTML; elt[elt.innerText ? 'innerText' : 'textContent'] = s.substring(0, options.maxStringLength); elt.className += ' sf-dump-str-collapse'; elt.innerHTML = '<span class=sf-dump-str-collapse>'+h+'<a class="sf-dump-ref sf-dump-str-toggle" title="Collapse"> &#9664;</a></span>'+ '<span class=sf-dump-str-expand>'+elt.innerHTML+'<a class="sf-dump-ref sf-dump-str-toggle" title="'+x+' remaining characters"> &#9654;</a></span>'; } } } catch (e) { } }; })(document); </script><style> pre.sf-dump { display: block; white-space: pre; padding: 5px; } pre.sf-dump:after { content: ""; visibility: hidden; display: block; height: 0; clear: both; } pre.sf-dump span { display: inline; } pre.sf-dump .sf-dump-compact { display: none; } pre.sf-dump abbr { text-decoration: none; border: none; cursor: help; } pre.sf-dump a { text-decoration: none; cursor: pointer; border: 0; outline: none; color: inherit; } pre.sf-dump .sf-dump-ellipsis { display: inline-block; overflow: visible; text-overflow: ellipsis; max-width: 5em; white-space: nowrap; overflow: hidden; vertical-align: top; } pre.sf-dump .sf-dump-ellipsis+.sf-dump-ellipsis { max-width: none; } pre.sf-dump code { display:inline; padding:0; background:none; } .sf-dump-str-collapse .sf-dump-str-collapse { display: none; } .sf-dump-str-expand .sf-dump-str-expand { display: none; } .sf-dump-public.sf-dump-highlight, .sf-dump-protected.sf-dump-highlight, .sf-dump-private.sf-dump-highlight, .sf-dump-str.sf-dump-highlight, .sf-dump-key.sf-dump-highlight { background: rgba(111, 172, 204, 0.3); border: 1px solid #7DA0B1; border-radius: 3px; } .sf-dump-public.sf-dump-highlight-active, .sf-dump-protected.sf-dump-highlight-active, .sf-dump-private.sf-dump-highlight-active, .sf-dump-str.sf-dump-highlight-active, .sf-dump-key.sf-dump-highlight-active { background: rgba(253, 175, 0, 0.4); border: 1px solid #ffa500; border-radius: 3px; } pre.sf-dump .sf-dump-search-hidden { display: none; } pre.sf-dump .sf-dump-search-wrapper { float: right; font-size: 0; white-space: nowrap; max-width: 100%; text-align: right; } pre.sf-dump .sf-dump-search-wrapper > * { vertical-align: top; box-sizing: border-box; height: 21px; font-weight: normal; border-radius: 0; background: #FFF; color: #757575; border: 1px solid #BBB; } pre.sf-dump .sf-dump-search-wrapper > input.sf-dump-search-input { padding: 3px; height: 21px; font-size: 12px; border-right: none; width: 140px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; color: #000; } pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next, pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous { background: #F2F2F2; outline: none; border-left: none; font-size: 0; line-height: 0; } pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next > svg, pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous > svg { pointer-events: none; width: 12px; height: 12px; } pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-count { display: inline-block; padding: 0 5px; margin: 0; border-left: none; line-height: 21px; font-size: 12px; }pre.sf-dump, pre.sf-dump .sf-dump-default{background-color:#fff; color:#222; line-height:1.2em; font-weight:normal; font:12px Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:100000}pre.sf-dump .sf-dump-num{color:#a71d5d}pre.sf-dump .sf-dump-const{color:#795da3}pre.sf-dump .sf-dump-str{color:#df5000}pre.sf-dump .sf-dump-cchr{color:#222}pre.sf-dump .sf-dump-note{color:#a71d5d}pre.sf-dump .sf-dump-ref{color:#a0a0a0}pre.sf-dump .sf-dump-public{color:#795da3}pre.sf-dump .sf-dump-protected{color:#795da3}pre.sf-dump .sf-dump-private{color:#795da3}pre.sf-dump .sf-dump-meta{color:#b729d9}pre.sf-dump .sf-dump-key{color:#df5000}pre.sf-dump .sf-dump-index{color:#a71d5d}</style><pre class=sf-dump id=sf-dump-49150229 data-indent-pad="  "><span class=sf-dump-note>array:6</span> [<samp>
  "<span class=sf-dump-key>post_key</span>" => "<span class=sf-dump-str title="10 characters">ckxv04dngt</span>"
  "<span class=sf-dump-key>title</span>" => "<span class=sf-dump-str title="6 characters">asdasd</span>"
  "<span class=sf-dump-key>content</span>" => "<span class=sf-dump-str title="6 characters">asdasd</span>"
  "<span class=sf-dump-key>seo_title</span>" => <span class=sf-dump-const>null</span>
  "<span class=sf-dump-key>category_id</span>" => "<span class=sf-dump-str>1</span>"
  "<span class=sf-dump-key>seo_desc</span>" => <span class=sf-dump-const>null</span>
</samp>]
</pre><script>Sfdump("sf-dump-49150229")</script>

hsntngr left a reply on How To Update The Record If It Exist Or If Not Create New Record

@bwrice you were right, I missed that -_- but still returns http status 500 without any error

hsntngr left a reply on How To Update The Record If It Exist Or If Not Create New Record

also there is no post_status field too ..