RoboRobok

RoboRobok

Member Since 3 Years Ago

Experience Points 20,640
Experience Level 5

4,360 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 16
Lessons
Completed
Best Reply Awards 24
Best Reply
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.

04 May
2 weeks ago

RoboRobok left a reply on What Should I Response In Login Process ?

@TISUCHI - What do you mean by status code? Any 200 response should be considered valid login.

RoboRobok left a reply on What Should I Response In Login Process ?

It depends what information you need. Is your app a SPA? Ask yourself if you need user name or anything to be displayed at this point. If so, the login endpoint can be a good one to return this.

02 May
3 weeks ago

RoboRobok left a reply on How To Stop Form From Submitting Twice

@PICKAB00 - abort(429) will just throw appropriate exception, you can still display a message. Always remember to return appropriate HTTP status codes.

RoboRobok left a reply on How To Stop Form From Submitting Twice

abort(429); is the way to go.

RoboRobok left a reply on How To Get Only One Row Of One To Many With Condition?

Impossible to do it efficiently and easily out of the box. Try the Eloquent Eager Limit package.

RoboRobok left a reply on How To Solve SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'id' In 'where Clause'

This „where id is different than one” wasn’t added magically, it’s somewhere in your code.

RoboRobok left a reply on How To Solve SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'id' In 'where Clause'

Do you have a call to addGlobalScope() somewhere in your model?

RoboRobok left a reply on How To Solve SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'id' In 'where Clause'

Just find the code adding this where clause and update the id name there. I don’t see the problem.

RoboRobok left a reply on POST Not Found In Request

First of all, that’s not the Laravel style to access $_POST directly. There is $request->has(...) method to check if a property exists. Do you send this request manually? Perhaps there is some issue with processing your payload as $_POST. Try sending a form or using a REST client and try again.

RoboRobok left a reply on How To Solve SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'id' In 'where Clause'

Are you sure it’s this query? If so, you must have a global scope there, adding where(id, <>, xxx) in the model.

RoboRobok left a reply on Redirect To Intended Page After Login - Laravel 5.7

@MARTINBEAN - I don’t think you ever need to put `url.intend to sessiob manually. That’s exactly what at `intend method does.

RoboRobok left a reply on Toggle Boolean

Use find() though.

RoboRobok left a reply on Toggle Boolean

Your where() + first() does the same thing as find().

I don’t know. You do something wrong. Just make sure the method is there.

RoboRobok left a reply on Toggle Boolean

Because where() returns a query builder. Do it with find() instead or call get() after where().

RoboRobok left a reply on Toggle Boolean

Again, my code will allow you to do so. find() returns a model instance and update() method works on a model. Just paste my code to your toggleFlag() method. But make sure you use it that way, because before you tried on a builder.

RoboRobok left a reply on Toggle Boolean

I’m pretty sure my code does exactly that.

RoboRobok left a reply on Toggle Boolean

Can your method just run the update query? How about this?

$this->update([
    ‚flag’ => DB::raw(‚NOT flag’)
]);

Writing on iPhone, sorry about the single quotes.

RoboRobok left a reply on Toggle Boolean

Because method written that way can’t work with the query builder.

19 Apr
1 month ago

RoboRobok left a reply on WHERE On Multiple Columns

That’s why I’m always afraid to ask questions for self-improvement. Some people read them without any intellectual processing, just answer as if I was a noob and willing to get a result. Luckily others understood the purpose of this question and the problem it’s aiming to solve.

RoboRobok left a reply on WHERE On Multiple Columns

@SNAPEY - I don’t think it has anything to do with my topic.

RoboRobok left a reply on WHERE On Multiple Columns

I'm being pedantic here, but I wish there was a simple forEach() method for the query builder, like this:

Article::forEach(['title', 'description', 'note'], function (string $columnName, Builder $query) {
    $query->orWhere($columnName, 'needle');
})->get();

It would allow to create beautiful iterated chains when necessary.

18 Apr
1 month ago

RoboRobok left a reply on Where Are You All From?

Poznań, Poland. <3

RoboRobok left a reply on Let User Upload Any Photo Size - Resize Later

File size is file API's work, not image API's. Storage will tell you the size of uploaded file just fine.

$size = $request->file('input-name')->getSize();

Source: Documentation of File Uploads

RoboRobok left a reply on Registration With Youtube Credentials In Laravel

Isn't YouTube just using Google accounts?

RoboRobok left a reply on WHERE On Multiple Columns

That would be pretty cool indeed. A scope taking an array of columns and a value as parameters.

RoboRobok started a new conversation WHERE On Multiple Columns

Hi guys,

I need to look for a value in several columns. I was thinking if there is any "cool" way to do it. What I did is:

$columns = ['title', 'description', 'note'];
$needle = 'carrot';

$articles = App\Article::whereIsPublic(true)
    ->where(function (\Illuminate\Database\Eloquent\Builder $query) use ($columns, $needle) {
        foreach ($columns as $column) {
            $query->orWhere($column, $needle);
        }
    })
    ->whereIsFinished(true)
    ->orderBy('title')
    ->get();

It creates the query I need just fine:

select *
from `articles`
where `is_public` = 1
and (
  `title` = "carrot"
  or `description` = "carrot"
  or `note` = "carrot"
)
and `is_finished` = 1
order by `title` asc

Is there any cooler Eloquent way? I don't like the foreach loop here.

Question for educational purposes :)

28 Feb
2 months ago

RoboRobok left a reply on Laravel 5.9 Wish List

I am really looking forward for better relationship definitions. They shouldn’t have been methods declared on both ends (DRY). Maybe in Laravel 6.0?

25 Feb
2 months ago

RoboRobok left a reply on TDD CSRF Mismatch

Are you using the built-in CSRF solution? If so, there is no reason to test it. You should just disable it for testing.

23 Feb
3 months ago

RoboRobok left a reply on How To Make A Page Accessible Only By Clicking On A Button?

Can you tell me why you don’t want it to have an URL? It doesn’t add anything to the security, but certainly it does for annoyance.

RoboRobok left a reply on How To Hide All Popovers On Document Click - Except The One Clicked

Just hide all and then show the clicked one.

22 Feb
3 months ago

RoboRobok left a reply on How To Make List Values Available For Multiple Controllers (drop Down View)

To be honest, I believe the most reliable way to solve this would be to make this dropdown a partial view of its own. And then, you would use View::compose on that view. You could make this view take a class name for the element to style it individually, for example.

21 Feb
3 months ago

RoboRobok left a reply on Laravel And AJax On Localhost Working, But Online Ajax Request Not Working With No Reponse

There are a few great articles about CORS online. Basically, you need to include Access-Control-Allow-Origin header in the response, preferably setting it to whatever the Origin request header was, of course if the Origin is acceptable.

RoboRobok left a reply on How To Get Record In Between Range Of Quantity?

Another idea is to us eDB::raw() like this:

test::whereBetween(DB::raw(16), [DB::raw('min'), DB::raw('coalesce(max, ~0)')])->get()

RoboRobok left a reply on Grouping By 15 Days( 1 ~ 15 ) / ( 16 ~ End Of Month ).

Group by raw expression. I would go with day(billing_date) <= 15 as SQL expression. Some records will interpret it as 0 and some will as 1. Good to group by that.

RoboRobok left a reply on How To Make List Values Available For Multiple Controllers (drop Down View)

@SHAHRUKH4 - I was talking about using it in subviews as well. But if you load it just for the main layout, you can still pass it to the subviews that need it, without querying the database over and ober again.

20 Feb
3 months ago

RoboRobok left a reply on How To Make List Values Available For Multiple Controllers (drop Down View)

@shahrukh4 I'm pretty sure your code will call one SQL query per each subview, which I don't think is the best idea.

How about querying it for the main view only and then passing to any view that needs it? Or binding that to the container?

RoboRobok left a reply on Standard Deviation Funtion?

@fbc if you mak your own helpers, try to stick to PSR standards and use camel case.

Also, as a rule of thumb, I think it's better to always use static instead of self, just to avoid surprised or bugs that are difficult to track whenever you extend your classes.

RoboRobok left a reply on Standard Deviation Funtion?

@cronix because global lookup works just for functions, not classes, traits etc.

RoboRobok left a reply on Does This Forum Support Emoji Of Any Kind?

It came out as a JPG.

But seriously, any other way?

RoboRobok started a new conversation Does This Forum Support Emoji Of Any Kind?

Emojis are converted here to question marks, standard Markdown like :smile: doesn't work neither, no luck with :) :D etc.

Is there any other way to post smileys here? If not, how about making it handle regular emoji just like our Laravel does?

RoboRobok left a reply on Standard Deviation Funtion?

Maybe an easter egg, haha ?

RoboRobok left a reply on Why Does This Website Go Back In Time When I Refresh It?

It's possible that it only works like that for new articles. I added one comment today and have experienced that, but also I've done the same in the past.

If you'd like to test, just casually open the website in a few minutes (they add news regularily), but keep in mind that it's now 3:34 am in Poland and they add news between 9 am and 12 am or something like that.

It's bad enough to be experienced even many minutes after the news has been added. I tried now too and it's consistent at the moment indeed. I guess their cache gets a lot of time to sync.

RoboRobok left a reply on Standard Deviation Funtion?

@cronix functions in global scoppe don't need to be namespaced in PHP. If the function is not found under current namespace, PHP automatically tries to resolve it under the global namespace.

RoboRobok left a reply on Why Does This Website Go Back In Time When I Refresh It?

Absolutely, you can see it. I didn't want to post the URL to avoid being called a spammer :D

The website is Pudelek (meaning 'little poodle' in Polish): www.pudelek.pl

RoboRobok left a reply on Code Shortcut For Route Function With Multiple Parameters

Hi Ray, I would consider using custom route parameter pattern, as described in Explicit Binding documentation, under Customizing The Resolution Logic section. You can add entire {country}/{city}/{post} combo as one URL parameter, returning whatever you like.

RoboRobok started a new conversation Why Does This Website Go Back In Time When I Refresh It?

There is a huge gossip website that behaves very weird. Every time you refresh, it shows you a different state of comments, like different point of time. You see there are 30 comments. You refresh, it's 32. You refresh again, it's 29. Then again 30 etc. And it's not just about the counter, there are actually that many comments displayed. Also, the thumbs up and down seems to reflect that point of time too. And this website is like that for years now, despite being a huge success.

My question is, how common that issue is? Can that be called purely bad content distribution and/or caching? Or is it something that cannot be avoided in some projects?

It's really annoying issue. Sometimes you write the comment and it required you to refresh several time to see it. And sometimes, if you refresh after seeing in, it's gone again. I guess it's not very common.

I would love to understand what can be some potential reasons for this behavior.