Ruffles

Ruffles

Senior PHP Developer at Adeva IT

Skopje, Macedonia

Member Since 4 Years Ago

Experience Points 300,630
Experience
Level
Lessons Completed 1206
Lessons
Completed
Best Reply Awards 153
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.

25 Nov
2 weeks ago

Ruffles left a reply on All Problems With The New Laracasts Design

I noticed that the list of the latest lessons seems to be cached and does not show all of the lessons. I've tried removing all of the filters but it did not help. Possible bug?

08 Nov
1 month ago

Ruffles left a reply on Accessing JSON In TEXT Columns

I believe that the second problem is there because the field you are trying to access is not a MySQL JSON field but a TEXT field.

For the first one, I am not sure if you can even cast it at all unless it is a MySQL JSON field.

Ruffles left a reply on Please Bring Back The Older Laracasts Design

Awesome user experience! I love it!

17 Sep
2 months ago

Ruffles left a reply on Execute Php Script With Axios

Why are you executing that script? Isn't it easier if you just run the code when the request gets to that route?

04 Jul
5 months ago

Ruffles left a reply on How To Develop 4 Images Upload And Saving System In Form In Laravel 5.6?

No, that would be a one to many relationship between vehicles and vehicle_images.

Ruffles left a reply on Laravel Failed To Create Project

That's probably because you didn't have internet access in your dev environment (Docker Container / Vagrant VM) when you ran the command or maybe it is your PC / Mac. Try ping github.com and see if you'll be able to connect.

15 Jun
5 months ago

Ruffles left a reply on Laravel 5.6 Job Event Queue::after Not Firing After Queue Processed

Did you restart the queue worker after you changed the code? It's daemon by default. Not sure if that affects the AppServiceProvider as well but that might be the problem.

22 Feb
9 months ago

Ruffles left a reply on Refactor A Lot Of Conditionals

You can do something like this:

$offer = Offer::find($offerId);

$errors = collect([
    'offer_expired' => $offer->hasExpired(),
    'offer_not_verified' => $offer->isNotVerified()
]);

$errors = $errors->map(function($isError, $errorType) {
    return $isError ? $errorType : null;
})->filter();

$errors ?  throw new CantApplyException($user, $offer, $errors) : return view('some view');

This is probably one way to clean it up but you should probably put this logic into a middleware or create custom validation rules and use them in a form request class.

08 Feb
10 months ago

Ruffles left a reply on Can Laravel 5.5 Horizon Use Controller Method Instead Of Closure?

That method is for authorization so only true or false is valid as return types, just like Form Requests and the authorize() method.

Ruffles left a reply on Effects Of Mass Assignment

It is a simple check to see if the fields coming from the request are part of the mass assignable fields array defined in the Eloquent model(s).

Laravel supports it out of the box so all you have to do is tell your Eloquent model which fields to accept when using Model::create($arrayOfFields) by using the protected $fillable array property in your Eloquent model(s).

Check the docs for more info

08 Jan
11 months ago

Ruffles left a reply on Connect API With Laravel Project

What does $res return in your try block?

If it does return the data, you should probably do something like:

return json_decode($res->getBody(), true);
07 Nov
1 year ago

Ruffles left a reply on 5 Reasons Why You Should Hire A Professional Web Design Company

This is a web development forum, not an article publishing platform like Medium.

03 Oct
1 year ago

Ruffles left a reply on Trying To Use Collect.js In Contoller

Why are you using collect.js in a PHP file?

Why not just use eloquent for that?

$users = User::orderBy('first_name', 'asc')->get();

Ruffles left a reply on Using JS And CSS In A Laravel Package

It should work as a normal app but make sure to either add a slash before js like /js/app.js or use the asset() helper.

27 Sep
1 year ago

Ruffles left a reply on How To Use JQuery Plugins With Vue

Why use a JQuery plugin when you could use a VueJS plugin for that?

12 Sep
1 year ago

Ruffles left a reply on API Authentication

When I am working with APIs, I use JSON Web Tokens (JWT) for authentication. It is easy to implement using a package like tymon/jwt-auth.

22 Aug
1 year ago

Ruffles left a reply on Multi Page Frorms And Api Backend

You would probably have a unique field (for example name) and based on that field, you could check if it exists, update it, else create a new record.

Ruffles left a reply on Multi Page Frorms And Api Backend

You could store the data partially in the database and have a completed field which unless it is 100, you won't show that record anywhere.

19 Jul
1 year ago

Ruffles left a reply on Using ->with()

One way is to use a Fractal Transformer and customize your own response.

17 Jul
1 year ago

Ruffles left a reply on Trying To Get Property Of Non-object

Look for it in the home.blade.php view file on line 1417 (wow, never seen a view file with that many lines)

11 Jul
1 year ago

Ruffles left a reply on Selfmade LengthAwarePaginator Returns Items Not In An Array And Thus They Can't Be Accessed Using Axios.get

What do you mean by it can't access collections?

you should be able to access your data by response.data in your javascript closure and just use a foreach statement to loop through it to display it on the page.

Another way to fix this problem is to transform the response from the controller.

02 Jun
1 year ago
24 May
1 year ago

Ruffles left a reply on Showing The Extract Of An Account

What are the relationships between the tables?

14 May
1 year ago

Ruffles left a reply on Manipulate JSON Before Return

Customize the response the way you want it, example:

return response()->json([
    'data' => [
         'id' => $model->id,
        // .....
    ],
    'meta' => [
        'requiresAuth' => false,
    ]
]);

Ruffles left a reply on CSRF Token In Lumen 5.4

JSON Web Tokens is one of the possible options. The JWT Auth package is quite easy to use.

Ruffles left a reply on CSRF Token In Lumen 5.4

No, you shouldn't.

Lumen is mainly used for RESTful APIs since Lumen 5.2, so the views functionality was removed.

CSRF tokens are used in a session based traditional application while the RESTful APIs are stateless and do not use sessions.

08 May
1 year ago

Ruffles left a reply on Learning Suggestion

Start with Wes Bos' JavaScript 30 tutorials. Also learn JavaScript to a point where you are comfortable to learn the new ES6 / ES2015 features before jumping on the framework train.

Ruffles left a reply on First Time With Laravel And Following Laravel 5.4 From Scratch: User Can't Sign In.

(the password is in plain text, not hashed.).

There's the problem. Laravel's login function (whichever you use) is comparing hashed passwords and that's why you can't login.

Hash the password with bcrypt($password) and it will probably work.

30 Apr
1 year ago

Ruffles left a reply on Any Freelancer Here?

Sign up on Upwork, set up your profile, find a project you like and apply for it

Ruffles left a reply on 500 Http Error - AJAX

When I want to pass an ID to the JQuery script, I usually use HTML5 data attributes on the button and just pick up the value in the script.

Example:

// The Blade file
<button type="button" id="button" data-id="{{ $model->id }}"> Button </button>

// The Script
var id = $('#button').data('id');

Most of the time I just hardcode the URL in the script but when I want to make it dynamic, I also use data attributes for the resource name similar to the example above.

Another idea that came to mind just now is that you could pass the whole URL via a data attribute, something like data-url, using Laravel's route() helper.

29 Apr
1 year ago

Ruffles left a reply on 500 Http Error - AJAX

What's the error? Check your Chrome Dev Tools Network tab for more details.

26 Apr
1 year ago

Ruffles left a reply on Custom "type" To The Class

@theUnforgiven Try this:

return redirect('admin/users')
                  ->with('flash', 'Account updated')
                  ->with('flashType', 'success');
21 Apr
1 year ago

Ruffles left a reply on How Much Do You Earn?

@fahaddsheikh I don't think that our profession (web development) is underpaid, it's just that it depends on the company and client you work for, and the complexity of the projects you work on.

If all you do is work on some projects which are simple CMSes / agency or company blogs and websites, you'll probably be paid less, because the responsibility is lower.

If you work on a bigger project, like an ERP / CRM, you would probably be paid higher because the responsibility is higher.

And to answer your question:

I didn't say that you shouldn't look for a better job position / salary, I was trying to say that it won't make much difference if you start comparing your salary with other people's salaries, because it heavily depends on the company they work for, the client they work for, the country they live in and many other things.

You just have to find the right company for you, because everyone has a different idea of what's their ideal job position.

Some people are just interested in the idea of having a job and that they can say that they work for a company and never go up the ladder or advance in their career. On the other hand, some other people care more about the organization, type of projects, how the projects are organized type of thing and can't just work for anyone and anything like me.

Get to a position where you can choose what you want and how you want, and you won't have a problem finding an amazing company.

17 Apr
1 year ago

Ruffles left a reply on How Much Do You Earn?

It does not matter how much you earn, as long as you can cover the living expenses.

16 Apr
1 year ago

Ruffles left a reply on Anyone Try The Micro Framework Equip?

I have not yet run into any problems with Lumen and PHP 7.1 so I guess it's supported.

14 Apr
1 year ago

Ruffles left a reply on Laravel Project On The Server Of Godaddy

By GoDaddy server you mean shared hosting?

09 Apr
1 year ago

Ruffles left a reply on I'm Starting To Hate Laravel

@endian Most of the features Laravel offers are used in bigger-than-just-a-blog projects at some point of the project's development cycle. If you work on an ERP / CRM app for a while, you'll notice that.

The only reason I am using a framework is because I wanna finish the project on time before the deadline hits. I could build everything from scratch but it will take a lot of time and effort. I might get stuck at some point but the client won't be like "Good job man, you are a serious developer. You are not using a framework".

All clients care about is a working project, they don't really care about the technical stuff. It's up to the developers to make their life easier.

31 Mar
1 year ago

Ruffles left a reply on Does Eloquent Prepare The Output Of The Data In The Collection When Relationships Are Eager Loaded?

I went with a different route, using group_concat and group_by, a little bit different than @jimmck 's example. Now I am getting them as strings which can be easily used in the future.

Thank you all for your contribution in this discussion!

28 Mar
1 year ago

Ruffles left a reply on JQuery Is Not Initialized When Using Laravel Mix 0.9.*

The docs on Laravel Mix Autoloading say that it will add it to every file JQuery is required.

Ruffles started a new conversation JQuery Is Not Initialized When Using Laravel Mix 0.9.*

Hello!

I just upgraded Laravel Mix to version 0.9 and I noticed that my template stopped working because JQuery is not being initialized before Bootstrap.

The error I am getting is the following:

Uncaught Error: Bootstrap's JavaScript requires jQuery

So I searched google and saw that the default autoloading for JQuery was removed. I tried to add it back with

mix.autoload({
   jquery: ['$', 'window.jQuery']
});

but that didn't help me, I still have the same problem.

How can I include JQuery to the webpack.config.js file manually?

Ruffles left a reply on Does Eloquent Prepare The Output Of The Data In The Collection When Relationships Are Eager Loaded?

I have managed to figure out a way to group the output in a way Eloquent does it, using arrays and standard classes like in my example. The only problem I have now is the pagination is not consistent. Different number of results are displayed depending on the roles assigned to the users.

For example: If all users have all 4 roles (will probably never happen, they might have 3 of those 4 roles in some cases.) and I have 30 records per page set, I will get only 9 records back. If I increase the number of records per page to 200, I will have 52 users returned. This is happening because the pagination is ran against the role_user table and with the output grouping (or transformation), I cut down the array of items down.

26 Mar
1 year ago

Ruffles left a reply on Does Eloquent Prepare The Output Of The Data In The Collection When Relationships Are Eager Loaded?

The desired output would be:

stdClass => 
   'email' => '[email protected]',
    // some other fields go here
   'roles' => [
      stdClass => [
          'name' => 'super_admin'
      ],
       stdClass => [
          'name' => 'client_manager'
      ]
   ]

this is how eloquent outputs the query but for some reason I get the following when I use the fluent query builder with joins:

[
    stdClass => [
       'email' => '[email protected]',
        // some other fields go here
       'role_name' => 'super_admin'
    ],
    stdClass => [
       'email' => '[email protected]',
        // some other fields go here
       'role_name' => 'client_manager'
    ],
]

Ruffles left a reply on Does Eloquent Prepare The Output Of The Data In The Collection When Relationships Are Eager Loaded?

My table schema is simple:

users table

id
email
password
...

roles table

id
name

role_user table

role_id
user_id

I am using the same schema from the package spatie/laravel-permission

25 Mar
1 year ago

Ruffles started a new conversation Does Eloquent Prepare The Output Of The Data In The Collection When Relationships Are Eager Loaded?

Hello there!

I am working on this project where I use the Fluent Query Builder and I am trying to recreate the same output from the eloquent relationship eager loading, User::with('roles')->get() for example, with join statements.

As a result I had duplicate rows for obvious reasons. I had a list of repeating email addresses with multiple role names for a many to many relationship.

My question is: Do I have to manually structure the objects where I have a nested object(s) for the relationships?

25 Feb
1 year ago

Ruffles left a reply on How Can I Access Children Data From The Parent In VueJS2?

To pass data from a parent component to a child component, use props. To pass data from a child component to a parent component use custom events.

Ruffles left a reply on "Real World" Example Of CRUD W/ Laravel & Vue (non SPA)

Build components and use props to pass jsonified data (json_encode($projects)) to the component.

Example:

<projects-list :projects="{{ json_encode($projects) }}"></projects-list>
20 Feb
1 year ago

Ruffles left a reply on When Starting A New Project With Multiple Components Like Website, Admin Panel, API, Subscriber Panel Etc. How Do You Structure It?

Building the project as packages might be useful but it has downsides like the need to update all packages every time you add new code in one of the packages.

19 Feb
1 year ago

Ruffles left a reply on Repository Pattern

As far as I know, there's form (request) validation for that, but I am not sure if model validation is needed (maybe in some cases) before each database write operation.