DEV Community

Cover image for 23+ Laravel Interview Questions (Answered) You Should Know

23+ Laravel Interview Questions (Answered) You Should Know

Alex 👨🏼‍💻FullStack.Cafe on January 08, 2020

Despite what people like to think about PHP, it is still the most dominant server-side language on the web and Laravel is the most popular framewor...
Collapse
 
dansilcox profile image
Dan Silcox

Nice overview :)

Highlights a lot of the key features of Laravel (I learnt a lot here!) and also a lot of the flaws of PHP and ways to work around them (e.g. lack of native enums!).

I think it's worth noting that, when optimising for readability rather than "cleverness", generally it's best to avoid things like "variable variables" as they just confuse things and there's normally a way to write the same thing in a less confusing manner :) Just because one can do things like that, doesn't mean one should!

Collapse
 
renorram profile image
Renorram Brandão

I think the "variable variables" thing is more like a trick question I've never seen somebody use this kinda thing and if somebody did I'd assume they are overcomplicating something

Collapse
 
dansilcox profile image
Dan Silcox

Yes exactly - treat it as a code smell.

Collapse
 
bkirev profile image
Bozhidar Kirev

Q12: How do you do soft deletes?

Then goes and explains what are scopes.

Collapse
 
dansilcox profile image
Dan Silcox

Soft delete could be implemented as a scope with a filter like where deleted = false :)

Collapse
 
sambenne profile image
Sam Bennett

Wouldn't you just use the SoftDeletes Trait? It seems pointless to use scopes to do soft deletes. Plus the question says how to do Soft Deletes but does not show anything to do with it. That would be a fail in my books and would show the person can't read.

Thread Thread
 
dansilcox profile image
Dan Silcox

Fair enough - I must admit I don't do Laravel on a daily basis so wasn't aware of the SoftDeletes trait - was just working out from the context of the OP's article that they were implying scopes could be used for soft deletes...

Collapse
 
bkirev profile image
Bozhidar Kirev

I think the author just messed up the copypasta :)

Anyone who is interested in proper explanation, please refer to laravel.com/docs/6.x/eloquent#soft...

Thread Thread
 
dansilcox profile image
Dan Silcox

Ah nice thanks for the link

Collapse
 
zaxwebs profile image
Zack Webster

This is great!
'Q12: How do you do soft deletes?' answers about scopes instead.
A 'paste' mistake, it seems. :)

Collapse
 
jorgeirun profile image
Jorge

Excellent recap! This clarifies a lot of concepts.

Collapse
 
divyamohankashyap profile image
DivyeMohan Kashyap

Amazing Article, I am now aware of few new things in Laravel.
Keep Posting!! :-)

Collapse
 
websitedesignnj profile image
Kenneth Walley

Hey Alex, This is a great overview on Laravel Interview Questions (Answered). Awesome, Thank you so much, Alex, for taking the time to write all this. It’s very helpful for us! Thank you.

Collapse
 
tkmanga profile image
Tkmanga

Amazing article! is really useful!

Collapse
 
bestinterviewquestions123 profile image
Best Interview Question

Hey, there are some solid inquiries. Here are a few additional queries from our list of Best interview question.

Collapse
 
edgardbraz profile image
edgardbraz

Brother, this post is Very useful! Thank you. There were features I actually didn't know yet. I'm gonna try it out right now. ;)