dlebedef

dlebedef

Member Since 1 Year Ago

Experience Points 6,190
Experience Level 2

3,810 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 58
Lessons
Completed
Best Reply Awards 0
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.

22 Mar
2 months ago

dlebedef left a reply on Handle HEIC Images

@BOBBYBOUWMANN - Hi, thanks for the answer! Unfortunately, even after installing intervention/image I'm sstill struggling...I would like to save the image as jpg but I can't make it work.

In my case I receive an array of images through a form:

foreach ($request->file('photos') as $key => $photo) {
    Image::make($photo)->resize(300, 200)->save('path_to_folder/foo.jpg');
}

I get this:

NotReadableException in Decoder.php line 26:
Unable to read image from path (/tmp/phpwwJ3RJ).

Any idea on how to move on?

dlebedef started a new conversation Handle HEIC Images

So my question is quite simple: how do I handle HEIC images? Validation in forms using mimes doesn't seem to work with heic as it is not available in the mimes types list (https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types).

I need to be able to upload photos from phones and then display them on the website. Of course conversion to other formats is fine with me, but I can't find anything that I could implement...

31 Jan
4 months ago

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@STAUDENMEIR - Not really interested into changing the max response time and/or other parameters so I managed to retrieve the data basing the query on your first solution:

select *,
(select min(date) from orders where user_id=users.id) as oldest_order,
(select min(date) from delivery_orders where user_id=users.id) as oldest_delivery_order,
(select min(date) from invoices where user_id=users.id) as oldest_invoice,
from users
order by least(oldest_order, oldest_delivery_order, oldest_invoice)

Thanks for your help.

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@STAUDENMEIR - And now I get this...

SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query (SQL: select *, (select min(date) from `orders` where `orders`.`user_id` = `users`.`id`) as `orders_count`, (select min(date) from `delivery_orders` where `delivery_orders`.`user_id` = `users`.`id`) as `delivery_orders_count`, (select min(date) from `invoices` where `invoices`.`user_id` = `users`.`id`) as `invoices_count` from `users` order by least(orders_count, delivery_orders_count, invoices_count))

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@STAUDENMEIR - I do! I have orders, deliveryOrders and invoices.

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@STAUDENMEIR - I'm trying your second code and I get this error:

Call to undefined method Illuminate\Database\Query\Builder::orders as oldest_order()

Any idea why?

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@STAUDENMEIR - Nope, I only need to know which user has the oldest (or newest, meaning opposite order) record, no matter if it comes from the table orders, delivery_orders or invoices. Essentially it's to know with whom there's been a less/more recente interaction.

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@DOUGLASAKULA - Ok, so this is not far from my solution as we retrieve all users and the perform the filtering. I was wondering if there was a "unique" SQL/eloquent solution more efficient than the foreach loop used only for the filtering.

dlebedef left a reply on Order By Oldest Entry Form Different Relationships

@DOUGLASAKULA - Yes but this way I only retrieve the last order. What I would like to achieve without too many operations is to retrieve the last record from all the orders, delivery_orders or invoices. As if I could put all of the users record (orders, delivery_orders and invoices) and retrieve the last one by date. So that I can then order my users by their last "activity".

dlebedef started a new conversation Order By Oldest Entry Form Different Relationships

Here is my case:

I have a table users. Each user may have many orders, many delivery_orders and many invoices.

Let's make it simple and say the tables are like this:

Users

  • id
  • full_name

Orders

  • id
  • user_id
  • date

Delivery Orders

  • id
  • user_id
  • date

Invoices

  • id
  • user_id
  • date

For each user I want the oldest (date) between orders, delivery_orders, invoices and then order all my users based on their relative oldest date.

I can achieve this by retrieving all my users and then do the filtering and ordering but is it somehow possible to do that through an eloquent request? What is the best and cleanest way to achieve this result?

13 Nov
7 months ago

dlebedef left a reply on Notify On New Connection From New Device

@CMDOBUENO - Indeed using the IP address can "complicate" things. I was initially thinking of using the IP to detect the country and maybe the city, although in some cases cities are too small and can easily/quickly change (I live in a small country and it is the case). So based on that maybe have a table:

  • browser_key
  • country
  • (city) ??
  • device
  • platform
  • browser

And on the client side:

  • cookie containing the browser_key

if there is a match no need to notify the user, it is probably (we can never be 100% sure) all fine. While if there is a mismatch or absence of the cookie (browser_key) we consider this as a new device, notify the user and store the data.

This solution wouldn't interfere with the client experience but only add this "annoying" email notification when a new device is detected. But to be honest how many times do we change country and or device/browser?

That said I also agree that it would be nice to have more native solutions when it comes to identifying devices.

dlebedef left a reply on Notify On New Connection From New Device

@CMDOBUENO - Sure and I totally agree, that's why in this circumstance I'm not looking to apply additional authentication mechanisms such a two-factor authentication.

What I'm looking to achieve here is not really to enhance the security of the system but add this additional "layer" where the user is informed of a new connection to his account.

Of course as you said it is not 100% safe, nothing really is, but it might help in finding some anomalies and irregularities without really compromising the user experience.

Anyway, thank you for your feedback!

dlebedef left a reply on Notify On New Connection From New Device

@M7VM7V - Great, thank you! Two-factor authentication is something I will definitely use in another project I'm working on and this looks like a great tutorial.

12 Nov
7 months ago

dlebedef left a reply on Notify On New Connection From New Device

@M7VM7V - The trusted_devices table is definitely something I could use. But let's say some great hacker uses my same device, platform, browser and because he's really talented he somehow figures out my password. So the application would look for a match in the trusted_devices and would get a positive response.

But would it help to also:

1- store the IP address for an additional "security" comparison 2- use a cookie associated with the table trusted_devices so that if absent a notification is sent to the user, while if present we check for that entry in the table and check the additional matches between devices, platforms and browsers (plus the IP address)

Now I understand that these two steps rely on elements that can "easily" be modified by users, but they do add additional controls that could help. I would for instance be notified if I logged from the same pc but from different browsers, only once though as then both browsers would have the cookie and the device information would be stored in the database.

dlebedef left a reply on Notify On New Connection From New Device

@M7VM7V - Well in that case I'll be able to store only one "current device". What I would like to do is that if he changes browser or device he gets notified of a new connection and stores the value. This way you get to have multiple "trusted devices".

Let's say I connect from my laptop, then for some reasons I connect to a public pc and connect to my account. Now if I go back to my laptop (which should be now trusted) I would still get notified, which is something I'd like to avoid.

dlebedef started a new conversation Thread/Question: Number Of Views

I've noticed that when in a thread, if we refresh the page the number of views keeps increasing. While I can understand that it might be complicated to have a system based on accounts and/or IPs, but wouldn't it be better to at least avoid counting the views of the publisher?

dlebedef started a new conversation Notify On New Connection From New Device

So here is what I would like to do:

  • when a user logs in sent him a notification if "device/browser" is new

Here is an idea on how to achieve that:

  • Use a "cookie" (some hash value) associated with a "user_sessions" table in the database where I store "browser", "platform" and "device". If they match no need to notify the user otherwise I store the new entry in the database and notify the user.

Is this a valid solution? Is there a better way of achieving this?

25 Apr
1 year ago

dlebedef left a reply on Compare Parent Data With Relationship Data

I ended up using join() to retrieve all the data:

$orders = \App\Order::with('constructionSite.workingHours')->has('constructionSite.workingHours')
  ->leftJoin('construction_sites', 'construction_sites.order_id', '=', 'orders.id')
  ->select('orders.*', 'construction_sites.*', 'construction_sites.id as csid')
  ->leftJoin('working_hours', 'working_hours.construction_site_id', '=', 'construction_sites.id')
  ->selectRaw('sum(working_hours.worked_hours) as tot_whs')
  ->groupBy('working_hours.construction_site_id')
  ->havingRaw('sum(working_hours.worked_hours) > orders.installation_planned_hours * 0.8')
  ->get();

But your solution is probably cleaner and faster to execute. Thanks!

24 Apr
1 year ago

dlebedef started a new conversation Compare Parent Data With Relationship Data

Here is my case:

  • Model Order
  • Model ConstructionSite
  • Model WorkingHours

An Order has one ConstructionSite which in turn can have multiple WorkingHours.

In my table Order I have a column "installation_planned_hours" and in my table WorkingHours I have a column "worked_hours".

What is the best and more efficient way to retrieve all Orders which total of "worked_hours" (remember Order->ConstructionSite->WorkingHours) is at least 80% of the "installation_planned_hours"?