lukegalea16

Member Since 1 Year Ago

Experience Points
4,740
Total
Experience

260 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
4,740 XP
Apr
16
4 weeks ago
Activity icon

Replied to DateTime Vs Timestamp

Is it possible to automatically detect the user's time zone from Laravel/PHP (from where his/her request is being made)? This can then be used to automatically convert the stored UTC timestamps to his/her locale time. Or would you suggest storing the user's preferred time zone in a DB?

Mar
10
2 months ago
Activity icon

Replied to Real Time Updating Dashboard

I'll have a look.

Cheers

Activity icon

Started a new Conversation Real Time Updating Dashboard

Hi, just like with other projects I am presenting the data from the DB in a Blade view and all is working well. However obviously when a new entry in the DB is created, the page needs to be refreshed for the new entry to appear. Is it possible to have real-time updates going on in a Blade View?

Dec
15
4 months ago
Activity icon

Started a new Conversation Laravel DB Event Listener

In one of my tables incoming data will be inserted from a Node JS application since another protocol other than HTTPS Requests is used. I also want to trigger an API Call to send an E-Mail/SMS when a certain message is received. In other projects I handled all of this from the same Laravel project. However in this case should I trigger said API Call from the Node JS project or is there a way to have a listener in Laravel which analyzes messages being stored into a certain table and send API Calls if need be.

Activity icon

Replied to Livewire - Passing Model Object Losing Variable Value

Ah understood - then how come the set property is true on the first render() ? i.e. this issue happens only when I press loadMore; in which case the set property is then lost.

Activity icon

Replied to Livewire - Passing Model Object Losing Variable Value

Understood - in fact I am maintaining the set property with each incoming request but found it a convenient property to add to the model since when I am looping through the object I can easily access said property. So what do you suggest please? I am still slightly confused as to why other variables which I pass to Livewire are maintained fully (they are just strings for example) - but what difference is there between passing a string and an object?

Activity icon

Started a new Conversation Livewire - Passing Model Object Losing Variable Value

I have a Tag model defined as follows.

class Tag extends Model
{
    use HasFactory;

    public $set;	// used to keep track of whether the tag was enabled in the form or not
}

The $set variable is used in between requests such that the blade view may know which tags where previously enabled to show them as checked again. The issue which I am facing is with Livewire's load more. Let's assume that the set variable is true when first passing the objects to Livewire. Upon pressing load more, the $tags variable in the Livewire Component still exists but the set parameter becomes null. This does not happen with other variables which I set in the Livewire component - other variables persist the value between load more functions.

Activity icon

Replied to Livewire Load More

Managed! Thank you :-)

Dec
14
5 months ago
Activity icon

Started a new Conversation Livewire Load More

Using Livewire I am using a Load More to fetch data - Is it possible to get a notification or variable set when the limit has been reached such that I can hide the 'Load More' option?

Activity icon

Replied to Livewire Datatables

Cheers! And you are referring to this library? (https://github.com/MedicOneSystems/livewire-datatables)

Activity icon

Replied to Livewire Datatables

I still use the datatables library heavily, as I have a legacy project that I still maintain, but I am slowly moving each table to use livewire instead.

Are you referring to this library? (https://github.com/MedicOneSystems/livewire-datatables)

How are you using Livewire to create your own datatables please?

Activity icon

Started a new Conversation Livewire Datatables

Is anyone using Livewire Datatables and can give his/her opinion on them? So far I've used Livewire with a Load More functionality. Livewire Datatables seems convenient and neat to use as opposed to bootstrap tables and implementing pagination from Livewire. Thoughts?

Activity icon

Replied to Building A Relationship

Thanks! missed this - will check it out :) to gather all device logs for all the different tags I guess that I should iterate through all the tags and append to one final array? I doubt that it is possible to call deviceLogs() on multiple tags.

Dec
11
5 months ago
Activity icon

Started a new Conversation Building A Relationship

I have the following Models:

  1. Tag which has an id, name, etc.
  2. Device which belongs to a tag and thus has a tag_id property as well as the Device ID which is IMEI
  3. DeviceLog which is incoming data, one of the properties is the Device ID which is the IMEI as well

What suitable relationship should I use to get the Device Logs from the Tags? Note that a Tag may have multiple devices. From the device it is easy to get the logs using the following relationship return $this->hasMany('App\Models\DeviceLog', 'device_imei', 'imei'); But I am not sure how to collect all the logs for tags.

One method which I am thinking of is the return an array of device IMEIs for selected tags and then use a whereIn method for the DeviceLog Model.

Activity icon

Replied to Saving Incoming Data From A Device

By using a number as id instead of a string like you planned will make the performance of the index better since the identifiers of the devices would make indexing a bit more complicated.

Excuse my lack of knowledge about indexing but does indexing take place automatically or do I have to start an 'indexing process' ?

Activity icon

Replied to Saving Incoming Data From A Device

yeah. i'm always a fan of following convention if you can do.

Do you for see issues in performance if the IMEI is used for relationships for example?

Activity icon

Replied to Saving Incoming Data From A Device

Thank you for your reply.

"You may find an instance of setting up a device, when you have some details but not yet have the IMEI."

  • When the device is logging data but does not have settings yet, should I save it using the IMEI or id then?

"IMHO its much easier to keep to using integer ids within Laravel as that means you can stick to convention when it comes to eloquent relationships will make your models a less complicated."

  • Agreed, however for the relationships you can still specify another or foreign key right?
Dec
10
5 months ago
Activity icon

Started a new Conversation Saving Incoming Data From A Device

I want to save incoming data from a SIGFOX device which has an id of '2E81FA' for example (this is similar to a transceiver IMEI). The data is transmitted through an API Call towards my backend. A user can then view logs for a device and/or set some settings such as notifications. Thus so far I have two tables - one with settings and one with messages/logs.

  1. When creating a new entry in the settings table for a device this may include the device ID '2E81FA' and the primary id/key can then be used to relate with the user
  2. When saving incoming data from the API call, should I save it using the device ID '2E81FA' or the primary id/key? What if no settings have been created for the device and the primary id/key does not exist yet?

Is there a noticeable improvement in speed/performance when relating using the primary id/key VS another ID such as '28E1FA'? Most often I try to use the primary id/key since this is shorter and to my knowledge it is faster to compare as opposed to comparing '2E81FA' for example.

Activity icon

Replied to Livewire Query Parameters And Resource ID

Fair enough :-) thanks for your help. For others facing a similar problem to mine, in my [email protected] method I am not passing $device to the view and so Livewire\DeviceLogs shows all records because $device is not defined. In [email protected] I am passing $device and so Livewire\DeviceLogs then finds $device as set or defined and returns the records for that device only.

Activity icon

Replied to Livewire Query Parameters And Resource ID

Ok my bad - figured out that instead of $imei I should call $this->imei

Activity icon

Replied to Livewire Query Parameters And Resource ID

I am passing the variable as follows @livewire('device-logs', ['imei' => '123456']) but the $imei variable is remaining undefined. What could the issue be?

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\DeviceLog;

class DeviceLogs extends Component
{
	public $perPage = 10;
	public $imei;

    protected $listeners = [
        'load-more' => 'loadMore'
    ];

    public function loadMore()
    {
        $this->perPage = $this->perPage + 5;
    }

    public function render()
    {
    	if(!isset($imei)){
    		$logs = DeviceLog::latest()->paginate($this->perPage);
    	}else{
    		$logs = DeviceLog::where('device_imei', $imei)->latest()->paginate($this->perPage);
    	}
    	// $this->emit('deviceLogStore');
        return view('livewire.device-logs',['logs' => $logs]);
    }
}
Activity icon

Replied to Livewire Query Parameters And Resource ID

Actually in my case I am not using user but a 'device' Model. Thus when going to /devices/1/logs I'd want to get the logs for that device with that resource id. From my controller can I pass the $id to livewire?

Activity icon

Started a new Conversation Livewire Query Parameters And Resource ID

I basically followed this guide (https://www.nicesnippets.com/blog/laravel-livewire-load-more-example).

However now I am not sure how to modify it such that when using methods such as 'show' in my Model Controller I can then load the records using Livewire for a particular resource only. For example I want to load records for user with ID of 1 only with Load More implemented as well.

Thanks

Activity icon

Replied to Livewire Vs Pagination

Hi Sinnbeck, when clicking 'Load More' I wanted my data to be appended within the same div rather than loading a new set of data in that div. I guess that pagination is still used?

Activity icon

Started a new Conversation Livewire Vs Pagination

I am looking to implement a section with messages from my DB with a 'Load More' functionality - thus I am not sure whether I should take the pagination route or use Livewire. Any comments or suggestions are appreciated.

Dec
03
5 months ago
Activity icon

Replied to Migration - Enter Columns Before Created_at And Updated_at Columns

Yes and this - I'm still in development so I will most likely do this to keep my migrations 'clean'. Thanks :-)

Activity icon

Replied to Migration - Enter Columns Before Created_at And Updated_at Columns

Well I already have other columns, which is why I asked if a 'before' exists. I could definitely do that yes but if a 'before' existed it would have been easier to always insert them before the created_at, not having to check what was previous to.

Anyways, just wanted to double-check. Cheers.

Activity icon

Replied to Migration - Enter Columns Before Created_at And Updated_at Columns

Hi guys, the laravel command ->after('column') inserts a column after a specified one in a migration. I am looking for the opposite i.e. to enter a column previous to or before another column.

Dec
02
5 months ago
Activity icon

Started a new Conversation Migration - Enter Columns Before Created_at And Updated_at Columns

Is there a way to always enter columns before the created_at column in migrations? The only option I know of is the after clause but then the name of the previous column in the DB has to be entered.

Nov
30
5 months ago
Activity icon

Replied to Laravel Transcations

I could use this - but I have to include each variable that I will be using in the transaction?

Activity icon

Replied to Laravel Transcations

In the //db operations section I should be using DB::transaction() ?

Activity icon

Started a new Conversation Laravel Transcations

Is it true that when executing multiple statements, Laravel transactions should be used to catch any errors? I tried using DB::transaction() but it is not finding basic variables in the Controller function such as Request. See code below:

DB::transaction(function () {
            foreach ($tags as $tag => $value) {
                if($value->set){
                    $noTagsSelected = true;
                    for($i = 0; $i<7; $i++){
                        for($j = 0; $j<4; $j++){
                            $value->{$weekTitles[$i] . '_'.($j+1).'_on'} = $request->input($weekTitles[$i] . '-'.($j+1).'-on');
                            $value->{$weekTitles[$i] . '_'.($j+1).'_off'} = $request->input($weekTitles[$i] . '-'.($j+1).'-off');
                            $value->{$weekTitles[$i] . '_'.($j+1).'_en'} = $request->input($weekTitles[$i] . '-'.($j+1).'-en');
                            $value->save();
                        }
                    }
                }
            }
        });
Nov
27
5 months ago
Activity icon

Replied to Naming Columns

thank you!

Nov
26
5 months ago
Activity icon

Started a new Conversation Naming Columns

I am building a schedule kind of application where in the DB the user can save up to four different on/off times for different days of the week. Thus for a week schedule module, some of the columns will include 'monday_1_start_time', 'monday_1_end_time', 'monday_2_start_time', ...

Is it ok to use numbers/integers in column names or should I write them in text?

Activity icon

Started a new Conversation Save Variable In Laravel Storage

Not sure if what I'm thinking makes sense - but is it possible to store single variables/values somewhere in Laravel storage rather than in a DB? Said variables can then be updated by an admin only for example.

Nov
24
5 months ago
Activity icon

Started a new Conversation Node JS Sequelize

Forgive me for this is not about Laravel/PHP but I can't figure this out. I am saving a Europe/Malta time in Sequelize (Node JS). However in my DB the time is saved with the correct time zone but it always has one hour less. What could the issue be?

Activity icon

Started a new Conversation DateTime Vs Timestamp

I have a device which will be sending information when a certain event occurs. The application is expected to work globally and so the device will send the time in its local timezone. For this field should I go for dateTime, dateTimeTz or Timestamp?

My reasoning is that if the device is local for that user and the user is in the same timezone of the device I can use dateTime?

Nov
18
5 months ago
Activity icon

Started a new Conversation Cross Origin Requests

I have a main Laravel project and several others which will be getting data through API calls from the main Laravel project. From a browser when hosted online, I will run into Cross-Origin requests. In the .ht access file of the main Laravel projects is it possible to allow several different subdomains to access the same main project?

Nov
17
5 months ago
Activity icon

Replied to Model Custom Function To Return Custom Data

Is there a way to get the string for event_type (instead of a number) when echoing the model?

Activity icon

Started a new Conversation Model Custom Function To Return Custom Data

I have a model with a column called event_type which stores said event as an integer. Is it possible to create a function inside the model such that I return a string based on the number? I can then call the method from a model instance.

Activity icon

Replied to Persist/Keep Data In GET Form After Submit

Cheers @rodrigo.pedra , just wanted to double check!

Activity icon

Started a new Conversation Persist/Keep Data In GET Form After Submit

I have a view/page with a GET Form and a simple text box called 'device'. When the user presses submits, the data should load in the table below the form where the text box exists. When returning back the user's result, the 'device' entered in the text box is gone. Is there a way to keep it?

I could pass the field from the Controller itself to the view, but I am looking for other options just in case this is not the best one.

Thanks

Activity icon

Started a new Conversation Pagination And Search Table

Can someone please provide me with a suitable example which loads several records into an HTML table and has the option to search as well. Pagination should be used due to the large amount of records.

Thanks Luke

Nov
16
5 months ago
Activity icon

Replied to Update Multiple Entities At Once

Same reasoning yeah. Was looking for someone who had done it before maybe.

Activity icon

Started a new Conversation Update Multiple Entities At Once

With one form PATCH, is it possible to update several entities? i.e. usually if I have a Model 'photo' and want to update photo with an id of 1 the route would then be patch (photos/1).

If I want to update photos 1,2 and 4 for example, should I do a patch route to (photos) and pass the IDs in the body?

Note: I am using model 'photo' just for the sake of the example.

Nov
13
6 months ago
Activity icon

Replied to How To Check If User Is Authenticated In API?

If an API is expected to be made from a browser where a user is already logged in through Auth. For example for pagination etc. api calls need to be made within the same Laravel project. Is it ok to use the Auth::check/Auth::user in the API controller in that case?

Thanks

Nov
12
6 months ago
Activity icon

Replied to API Http Client Not Working Properly

It was a cache/config error!