RoboRobok

RoboRobok

Member Since 3 Years Ago

Experience Points 21,050
Experience Level 5

3,950 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.

13 Jun
1 week ago

RoboRobok left a reply on Single Page App On Homestead

I never know how to configure Homestead to keep my config when I update it.

RoboRobok left a reply on Single Page App On Homestead

I know that. My question is how to use index.html. I’m not using Laravel here.

RoboRobok started a new conversation Single Page App On Homestead

Hi guys,

I'd like to create a Single Page App and test it on Homestead server. Everything works fine if I use /public/index.php file - all URLs in my domain are being handled by this file - but how can I tell Homestead to use index.html instead?

08 Jun
2 weeks ago

RoboRobok left a reply on Allow To Login With Passwords

Just use another guard whenever needed.

RoboRobok left a reply on Start New Query Builder On Model's Table

I experimented a little and yes - the answer is getQuery()! It works perfectly fine (example using Invoice model):

$stats = Invoice::getQuery()
    ->whereBetween(DB::raw('date(issued_at)'), [$from, $to])
    ->groupBy('date')
    ->get([
        DB::raw('date(issued_at) as date'),
        DB::raw('sum(total_value) as total_value_sum')
    ]);

So it does exactly the same thing as replacing Invoice::getQuery() with DB::table((new Invoice)->getTable()).

Thanks @nash !

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - To call a non-static method on it. How else would you get a table name?

RoboRobok left a reply on Start New Query Builder On Model's Table

I tried using query() method (as I said in the original post), but it just starts new query, still being Eloquent Query. Not sure if getQuery() method exists, I will check it out.

RoboRobok left a reply on Start New Query Builder On Model's Table

Okay, let’s go back to my original question, because we are going nowhere with that debate.

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - You answered yourself - Active Record is used to make it easier. That also means it’s higher level. I really understand how it works, just think your naming convention is backwards.

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - Scope will work, it’s just a little awkward, as it’s meant to narrow the query, not to do something completely different. But yeah, from practical point of view it will work.

I completely don’t get your understanding of high/low level. Eloquent is just as much high level as Doctrine. You use some weird definition. If class A serves to give more power to class B, it means that class A is higher level than class B. And that is clearly the case with Eloquent vs. PDO. The latter one is just a library to use SQL in a more convenient manner. Eloquent use composition relationship on PDO, so how can PDO be more high level?

RoboRobok left a reply on Start New Query Builder On Model's Table

Please try to re-read my question if you’d like to try to answer.

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - Eee no? Eloquent is higher level that PDO, as it uses PDO under the surface.

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - Why would you go so low level, using PDO though?

RoboRobok left a reply on Start New Query Builder On Model's Table

@NASH - As an example, I needed to get some stats, using groupBy and some raw things inside get(). It’s actually weird that it still returns models after using groupBy.

RoboRobok left a reply on Start New Query Builder On Model's Table

@JLRDW - Interesting idea. A little quirky, but interesting. Are you sure there is no built-in method doing that?

RoboRobok started a new conversation Start New Query Builder On Model's Table

Hi guys,

is there any helper method to start new Query Builder on Model's table? I need to return some raw data to get a pure Collection, not Eloquent Collection of models.

In other words, I'm looking for a helper doing returning DB::table((new MyModel)->getTable()).

I know there's a query() method on Model, but it doesn't do that. It just starts new Eloquent Query.

01 Jun
3 weeks ago

RoboRobok left a reply on Angular2+. What’s You’re Opinion?

Angular and Vue.js are alternatives, Angular being more complex solution. I'm personally not a fan of Angular. It's just not fun to use and Vue.js is more than enough for me in terms of comprehensiveness.

31 May
3 weeks ago

RoboRobok left a reply on Why So Many People Leave Whitespace In Their Images?

I don't rip off their images, I often need a logo of something. You wouldn't believe how hard is it to find a logo without the whitespace sometimes.

RoboRobok left a reply on Why So Many People Leave Whitespace In Their Images?

Any images used by the websites. Logos, icons, diagrams etc.

RoboRobok started a new conversation Why So Many People Leave Whitespace In Their Images?

This drives me crazy. Whenever I look for an image, half of them appear to have some kind of padding inside. Vector or raster - doesn't matter. Their canvas in just larger than needed, having the white or transparent background inside.

Why do people do that?

29 May
3 weeks ago

RoboRobok left a reply on Logging In Laravel

Yes, putting Log::info() in production can be useful in some cases. It all depends what kind of data you want to collect.

RoboRobok left a reply on Breadcrumb With Laravel API

There are some really cool packages doing exactly that. Just google laravel breadcrumbs and you should fine the inspiration.

RoboRobok left a reply on How To Avoid Repeating Logic For Client- And Server-side?

To be honest I'm just asking from curiosity. I used to duplicate the code, but web sockets seems like a good idea. However, in some projects it could be an overhead to use web sockets just for this purpose. In a game, on the other hand, web sockets are useful to have anyway.

RoboRobok left a reply on How To Avoid Repeating Logic For Client- And Server-side?

Yes, I forgot to include that as one of the points. I'm not sure how instant are the responses in practice. For this purpose, the decent solution should provide 100% instant responses.

RoboRobok started a new conversation How To Avoid Repeating Logic For Client- And Server-side?

Let's say I create a game like Scrabble. It uses a client-side scripting to handle user interface and server-side code to store games, moves etc.

Now, I would like to let users know if their move is correct. If they place a tile on a field they weren't supposed to, the game lets them know by disabling the OK button or whatever. But the same validation takes place on server side obviously in case someone tries to use the API directly.

What are the possibilities to avoid repeating the game rules in JavaScript and PHP? Some ideas I can think of:

  1. Just validate on the server side and use Fetch/Ajax to know if the movement can be done. I don't like this idea though, because the response won't be instant.

  2. Protect the API some other way to be sure that the movement came from the client. I don't like this idea neither, because there is no 100% method and I wouldn't like to end up with screwed up games.

  3. Use Node.js to have it all in JavaScript. I'm not sure how much Node.js can be easily shared with the client-side code, but it's probably the idea that is closest to having just one codebase. I don't use Node.js, but I could consider having is as a service for this single purpose.

What do you guys think? My current approach is to just ignore the DRY principle and having my code in PHP and JS. That is not something I'm proud of though.

04 May
1 month 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
1 month 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
2 months 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.