Ruffles

Senior PHP Developer at Adeva IT

Experience

296,450

152 Best Reply Awards

  • Member Since 3 Years Ago
  • 1175 Lessons Completed
  • 157 Favorites

17th September, 2018

Ruffles left a reply on Execute Php Script With Axios • 5 days ago

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

4th July, 2018

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

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

Ruffles left a reply on Laravel Failed To Create Project • 2 months ago

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.

15th June, 2018

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

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.

22nd February, 2018

Ruffles left a reply on Refactor A Lot Of Conditionals • 7 months ago

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.

8th February, 2018

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

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 • 7 months ago

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

8th January, 2018

Ruffles left a reply on Connect API With Laravel Project • 8 months ago

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);

7th November, 2017

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

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

3rd October, 2017

Ruffles left a reply on Trying To Use Collect.js In Contoller • 11 months ago

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 • 11 months ago

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.

27th September, 2017

Ruffles left a reply on How To Use JQuery Plugins With Vue • 11 months ago

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

12th September, 2017

Ruffles left a reply on API Authentication • 1 year ago

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.

22nd August, 2017

Ruffles left a reply on Multi Page Frorms And Api Backend • 1 year ago

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 • 1 year ago

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.

19th July, 2017

Ruffles left a reply on Using ->with() • 1 year ago

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

17th July, 2017

Ruffles left a reply on Trying To Get Property Of Non-object • 1 year ago

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

11th July, 2017

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

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.

2nd June, 2017

Ruffles left a reply on Php (Laravel) Developer - Looking For Part-time/full-time Outsourcing Job • 1 year ago

Go on Upwork and apply for the job you like.

25th May, 2017

24th May, 2017

Ruffles left a reply on Showing The Extract Of An Account • 1 year ago

What are the relationships between the tables?

14th May, 2017

Ruffles left a reply on Manipulate JSON Before Return • 1 year ago

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 • 1 year ago

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 • 1 year ago

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.

8th May, 2017

Ruffles left a reply on Learning Suggestion • 1 year ago

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. • 1 year ago

(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.

30th April, 2017

Ruffles left a reply on Any Freelancer Here? • 1 year ago

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 • 1 year ago

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.

29th April, 2017

Ruffles left a reply on 500 Http Error - AJAX • 1 year ago

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

26th April, 2017

Ruffles left a reply on Custom "type" To The Class • 1 year ago

@theUnforgiven Try this:

return redirect('admin/users')
                  ->with('flash', 'Account updated')
                  ->with('flashType', 'success');

21st April, 2017

Ruffles left a reply on How Much Do You Earn? • 1 year ago

@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.

17th April, 2017

Ruffles left a reply on How Much Do You Earn? • 1 year ago

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

16th April, 2017

Ruffles left a reply on Anyone Try The Micro Framework Equip? • 1 year ago

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

14th April, 2017

Ruffles left a reply on Laravel Project On The Server Of Godaddy • 1 year ago

By GoDaddy server you mean shared hosting?

9th April, 2017

Ruffles left a reply on I'm Starting To Hate Laravel • 1 year ago

@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.

31st March, 2017

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

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!

28th March, 2017

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

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.* • 1 year ago

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? • 1 year ago

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.

26th March, 2017

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

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? • 1 year ago

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

25th March, 2017

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

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?

25th February, 2017

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

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) • 1 year ago

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

Example:

<projects-list :projects="{{ json_encode($projects) }}"></projects-list>

20th February, 2017

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? • 1 year ago

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.

19th February, 2017

Ruffles left a reply on Repository Pattern • 1 year ago

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.

17th February, 2017

Ruffles started a new conversation When Starting A New Project With Multiple Components Like Website, Admin Panel, API, Subscriber Panel Etc. How Do You Structure It? • 1 year ago

Hey there,

I am starting a new project and I am wondering if thinking about scalability is a good idea at the beginning when I have no idea about any stats.

So my question is:

When starting a new project which has multiple components like Website, Admin panel, Subscriber panel, API, iOS app, Android app and maybe a few more, do you:

  • Build them all as one Laravel application
  • Build an API in Laravel / Lumen and use front end frameworks like VueJS / Angular / AngularJS / React
  • Build each component in a different Laravel application, so you end up with like 4, 5 or maybe more Laravel applications which most of them will share the same features and / or models

15th February, 2017

Ruffles left a reply on Did I Lose My Search Privilege? • 1 year ago

CTRL + F5 (hard refresh) fixed it.

12th February, 2017

Ruffles left a reply on Essential Quals/experience For A PHP Developer? • 1 year ago

I would say that motivation and drive to learn and get better every single day is the most important skill you can have.

I would say that Laracasts is probably your best resource for Laravel which helped me to find a job and help colleagues. Oh and it's an amazing feeling when I can mention watching Laracasts videos on my LinkedIn profile as experience and colleagues at my first company say stuff like "Are you Ruffles from the Laracasts forums?!" :D Thanks @JeffreyWay

I learn mostly from video tutorials so I am subscribed to some other popular web development video tutorial platforms besides Laracasts.

I've also bought a few useful PHP / Laravel courses which I've learned a lot from (haven't touched Adam Wathan's book Refactoring to Collections and his course Test Driven Laravel yet).

I also watch conference talks to get some tips and tricks, help people on these forums here from time to time and I have a few books that I want to read but I have not found any free time to focus on them. Newsletters are piling up in my email and I read some of them.

Before I forget, I also learn a lot from working on real projects where I have to implement different features for clients. It taught me how to figure out stuff on the spot, by reading docs, googling and asking people on forums or the Larachat slack channel.

Maybe the Awesome Laravel list will help you find some resources.

Attending Laracon is not a bad idea, if you have the money and time to attend it. Laracon Online will be interesting.

I don't see much value in certificates really, because the technology is moving so fast and they might be useless after a while. Adopting a new technology quickly is more important than a certificate if you ask me.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.