theUnforgiven

theUnforgiven

Web Developer at NRS

Member Since 5 Years Ago

UK

Experience Points
289,050
Total
Experience

0 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
1643
Lessons
Completed
Best Reply Awards
45
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.

Level 50
289,050 XP
Apr
01
2 days ago
Activity icon

Started a new Conversation Filesystem Uploading, Since Using Vapor

Ever since I started using Vapor, my S3 storage upload's don't see to be working.

 $s3 = Storage::disk('s3')->putFile($path, $decoded_image, 'public');
            $url = Storage::disk('s3')->url($path);

I'm not sure why and don't really see any errors.

Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

No, it seems like the frontend is working as expected with the countdown but the two don't marry up, so having to re-think how to do it.

Activity icon

Awarded Best Reply on Updating One Modal/table From Controller And The Other Table

On the user modal I got it working by hunting around the docs etc.

public function completeAlerts($path)
    {
         // update the alerts for this user
         $this->alerts()->where('url', '/'.$path)
           ->update([
                'completed' => 1,
           ]);
    }
Activity icon

Replied to Updating One Modal/table From Controller And The Other Table

On the user modal I got it working by hunting around the docs etc.

public function completeAlerts($path)
    {
         // update the alerts for this user
         $this->alerts()->where('url', '/'.$path)
           ->update([
                'completed' => 1,
           ]);
    }
Activity icon

Replied to Updating One Modal/table From Controller And The Other Table

I have this in the controller, but want it in the modal

Alerts::where('user_id', user()->id)
                ->where('url', $request->path())
                ->update([
                    'completed' => 1,
                ]);
Activity icon

Replied to Updating One Modal/table From Controller And The Other Table

In essence rather than doing:

$comment = App\Comment::find(1);

$comment->text = 'Edit to this comment!';

$comment->save();

Within the controller, I want do something like Alert::where('url', $url)->setCompletedColumn(1)->update();

Activity icon

Started a new Conversation Updating One Modal/table From Controller And The Other Table

I'm sure there is a way to do this, just can't find it within the docs and can't remember for the life of me.

So I have I a user table, this user table hasMany Alerts (alerts table) But when something else takes place, i.e the complete a form, I want to be able to update the alert from the modal rather than writing all the logic within the controller method.

How does one do this?

Mar
31
3 days ago
Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

Great, thank you both @bobbybouwmann @snapey think I understand now, my bad!

Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

Ah, I see now.

So I just need an endpoint to get the session from, then have a timeout function within the Vue component to calculate when it should it that end point, is that my understanding?

I also have a sweet alert within the code to show to the user whether to stay logged in or log out.

Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

I do ping the backend like so:

$user = User::where('id', user()->id)->first();
	    $session = \DB::table('sessions')
	        ->select('last_activity')
	        ->where('user_id', $user->id)
	        ->first();
	    if($session->last_activity < now()->addMinutes(45)) {
	        $session->last_activity = \Carbon\Carbon::now()->getTimestamp();
	        $session->update();
	        Auth::login($user);
	    } else {
	        $session->delete();
	    }
	    return $session;

its more the timer i need sorting i think to show at 43 mins from the session, been made

Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

I have the above code, which seems to work, but on every page it's reset to 45 mins...

Anyone have any better suggestions on this.

Mar
21
1 week ago
Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

Not perfect by any means, but does the job:

<template>
	
</template>

<script>
    export default {
        data() {
            return {
                timerCount: 45
            }
        },
        watch: {
            timerCount: {
                handler(value) {
                    if (value > 0) {
                        setTimeout(() => {
                            this.timerCount--;
                        }, 45 * 1300);
                    }
                    if(value == 5) {
                    	swal({
                            title: 'Your session is about to expire!',
                            text: 'Your session will expire in 5 minutes, you can carry on or end your session.',
                            icon: 'error',
                            buttons: {
                            	cancel: {
							    text: "No, logout!",
							    value: null,
							    visible: true,
							    className: "",
							    closeModal: true,
							  },
							  confirm: {
							    text: "Keep me signed in.",
							    value: true,
							    visible: true,
							    className: "",
							    closeModal: true
							  }
                            }
                        }).then(okay => {
                            if(okay) {
                                axios.post('session');
                                this.timerCount = '';
                                this.timerCount = 45;
                            } else {
                                console.log('Logout');
                                axios.post('session/logout');
                                window.location = '/login';
                            }
                        	
                    	});
                   	}
                },
                immediate: true
            }
        }
    }

</script>
Mar
20
2 weeks ago
Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

Ok, so got the Vue component working and Sweet Alert showing, How do I update the session for that user, if they click "leave signed in" button.

I've got a route setup and an axios post request setup. Just unsure on how to reset their session

Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

Yes, that's kinda what I thought so just been playing with a new component which I should be able to add to the main layout file in order to trigger it.

<template>
	<div>
		Session: {{ timerCount }}
	</div>
</template>

<script>
    export default {
        data() {
            return {
                timerCount: 30
            }
        },
        watch: {
            timerCount: {
                handler(value) {
                    if (value > 0) {
                        setTimeout(() => {
                            this.timerCount--;
                        }, 1000);
                    }
                    if(value == 1) {
                    	swal({
                            title: 'Your session is about to expire',
                            text: 'You can click continue to keep your session alive for another 45 mins',
                            icon: 'error',
                            button: 'Continue',
                        });
                    }
                },
                immediate: true
            }
        }
    }

</script>
Activity icon

Replied to Session, Logout/Login Question, Countdown To Log Back In

@bobbybouwmann - Thanks dude, I'm using Vue so just thinking (help appreciated) on how I can get this to run. I presume just pass the current session to a Vue component and then within that have the timeout and button to go the action(s)?

Mar
19
2 weeks ago
Activity icon

Started a new Conversation Session, Logout/Login Question, Countdown To Log Back In

Hi all,

Hope everyone is safe from the virus & managing to keep busy.

I want to have a script ideally in VueJS that checks the current session (currently set to 45 mins in the env) that alerts the user when at 44 mins, with a countdown, then two buttons to stay logged in, or logout.

Obviously stay logged in will increase their session by another 45 mins., logout, well logs out and ends session.

So question is how would achieve this?

Mar
18
2 weeks ago
Activity icon

Commented on Twitter Clone Setup

You always leave us in limbo Mr Way.... 😂😂😂

When can we expect the next couple of eps?

Activity icon

Replied to Custom Tool Creation

Also running composer update shows

The requested package package-name could not be found in any version, there may be a typo in the package name.

Activity icon

Replied to Custom Tool Creation

Yes, this is what i've done but I get Class 'Acme\PriceTracker\PriceTracker' not found

Activity icon

Replied to Custom Tool Creation

@sti3bas of course, thank you. Will give this a watch

Activity icon

Started a new Conversation Custom Tool Creation

Hi all,

I've created a custom tool as per the docs, but when I register it within the nova service provider it states not found class exception....

Do I need to run composer install also? Or am I missing something else as it just doesn't seem to register it and I get Class 'Acme\PriceTracker\PriceTracker' not found

Activity icon

Started a new Conversation Session, Timeout Question [Help]

Hi all,

I have set the session timeout from 120 minutes to 20 mins. However if I stay logged in and then either go to another tab or don't use the browser, this should log me out, right?

However, I don't always see this happening, and I was trying to complete quite a long form on page, whilst doing other tasks away from the browser, so my question is; Is the "Idle" time from one request to another request? i.e clicking another link or a button on a form?

Mar
05
4 weeks ago
Activity icon

Replied to File Upload

Just use the component, post with axios and then in your controller dd($request->all()) will show you what is within the request and then save, manipulate as you wish

Mar
04
4 weeks ago
Activity icon

Replied to Vapor Uploading Files

@bobbbbb I'm not sure that is the issue as I have the API keys set within the env and also setup to connect to AWS via Vapor depolyments.

Mar
02
1 month ago
Activity icon

Replied to Timestamps In VueJS With MomentJS Not Showing On Both Chat Screens

Anyone have any suggestion on this and why it would work like this and not in realtime?

Feb
28
1 month ago
Activity icon

Replied to Vapor Uploading Files

Pointless comment?

Activity icon

Replied to Vapor Uploading Files

Anyone else have any suggestions?

Feb
27
1 month ago
Activity icon

Replied to Vapor Uploading Files

@kickinbrain I have the following in the bootstrap.js file

window.axios.defaults.headers.common = {
    'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
    'X-Requested-With': 'XMLHttpRequest'
};

Which by my understanding should take care of CSRF?

Activity icon

Replied to Vapor Uploading Files

Anyone?

Activity icon

Replied to SES On Vapor

@nie7321 When you say change the services config, how did you do this to specify what region to use?

Activity icon

Started a new Conversation Vapor Uploading Files

Hi all,

I have my AWS all setup in .env and Vapor deploy all works etc. But I have a new Vue component, to upload files.

<template>
    <div class="mt-2 mb-2 mr-2">
        <input type="file" id="file" ref="file" @change="upload" class="form-control">
        <div v-if="isUploaded">
            <div class="alert alert-success">File uploaded successfully</div>
        </div>
    </div>
</template>

<script>
    export default {

        data() {
            return {
                isUploaded: false,
            }
        },

        methods: {
            upload() {
                Vapor.store(this.$refs.file.files[0], {
                    progress: progress => {
                        this.uploadProgress = Math.round(progress * 100);
                    }
                }).then(response => {
                    console.log(response)
                    axios.post('/api/file/upload', {
                        uuid: response.uuid,
                        key: response.key,
                        bucket: response.bucket,
                        name: this.$refs.file.files[0].name,
                        content_type: this.$refs.file.files[0].type,
                    })

                    this.isUploaded = true;
                });
            }
        }
    }
</script>

But I'm seeing these errors and not sure why, as I have followed the Vapor docs.

Any help greatly appreciated

cc @themsaid

Feb
25
1 month ago
Activity icon

Replied to Timestamps In VueJS With MomentJS Not Showing On Both Chat Screens

<li class="media" v-for="(conversation,index) in conversations" :key="index">
                                <i class="far fa-user mr-3 img-thumbnail"></i>
                                <div class="media-body">
                                    <h5 class="mt-0 mb-1">
                                        {{ conversation.user.name }}
                                    </h5>
                                    <p>
                                        {{ conversation.message }}<br />
                                        <small class="text-muted pt-1">{{ conversation.created_at | formatDate }}</small> 
                                    </p>
                                </div>
                            </li>

Is the piece of code in question, the for formatDate is a Vue filter

Vue.filter('formatDate', function(value) {
    if (value) {
        return moment(String(value)).format('DD/MM/YYYY - hh:mm a')
    }
});
Activity icon

Started a new Conversation Timestamps In VueJS With MomentJS Not Showing On Both Chat Screens

Hi all,

I have this:

Which is two chat screens, left is a Tenant, right side is an Owner/Landlord.

My question is I use the created_at timestamp from the database, but the timestamp only shows in realtime on the side that is sending the message and not both, I have to refresh to see this. I am using Pusher and everything works fine and pretty much instant, just the timestamp thing is not quite working..

Any one have any suggestions?

Thanks in advance ;)

Feb
21
1 month ago
Activity icon

Replied to Adding Data To A Component From Another

For future me and anyone else.

I added

created() {
        Bus.$on('expenditure', (data) => this.addExpenditure(data))
    },

Then in the method added:

addExpenditure(data) {
            data.forEach((value, index) => {
                this.form.expenditureList.push(value);
            });
        },

Works perfect ;)

Feb
20
1 month ago
Activity icon

Replied to Adding Data To A Component From Another

Anyone know how to achieve this?

Activity icon

Replied to Adding Data To A Component From Another

So the event info:

name:"expenditure"
type:"$emit"
source:"<Root>"
payload:Array[1]
0:Array[2]
0:Object
1:Object

I need to push that into my form object on the parent, but as its an array, array object, do I need to map over these or is there an easier more sustainable way?

Activity icon

Replied to Adding Data To A Component From Another

Thanks, will check this out.

Activity icon

Replied to Adding Data To A Component From Another

So I have added an event to my child component <expenditure> as follows:

save() {
                this.$emit('expenditure', this.inputs);
                swal({
                    title: 'Expenditure',
                    text: 'The expenditure details have been saved, please continue.',
                    icon: 'success',
                    button: 'Continue',
                });
            },

Which if I view devtools I can see an array within the event. So in side my parent component <add-property> I need to get that event ideally when the continue button from the Sweet Alert is pressed. Which again I'm not sure how to do that.

Feb
19
1 month ago
Activity icon

Replied to Adding Data To A Component From Another

Ok, i’ll check this out. Or is there a simple way to pass what is in expenditure component to the parent another way? Not really to the form object but just so I can collect that data and post with axios.

Activity icon

Started a new Conversation Adding Data To A Component From Another

Hi all,

I have a component and inside this I have another

<div class="col-md-12">
        <expenditure></expenditure>  
</div>

So, my question is how can I add what comes from the expenditure component to the parent components form object?

Feb
18
1 month ago
Activity icon

Awarded Best Reply on Flatpickr And Calculate Date Lengths

Actually managed to just replicate

 updateEndDate() {
                var dates = this.form.start_date.selectedDates;
                var duration = this.form.duration;
                var startDate = moment(dates);
                var endDate = null;

                if (duration.length > 0 && startDate.isValid()) {
                    let durationInt = duration.replace(/\D/g,'');
                    let durationKey = duration.includes('years') ? 'y' : 'M';
                    endDate = startDate.add(durationInt, durationKey).subtract(1, "days");
                    
                    this.endDate = endDate.format('Do MMMM YYYY');
                } else {
                    this.endDate = '';
                }
            }

Useful for anyone else and my future self ;)

Activity icon

Replied to Flatpickr And Calculate Date Lengths

Actually managed to just replicate

 updateEndDate() {
                var dates = this.form.start_date.selectedDates;
                var duration = this.form.duration;
                var startDate = moment(dates);
                var endDate = null;

                if (duration.length > 0 && startDate.isValid()) {
                    let durationInt = duration.replace(/\D/g,'');
                    let durationKey = duration.includes('years') ? 'y' : 'M';
                    endDate = startDate.add(durationInt, durationKey).subtract(1, "days");
                    
                    this.endDate = endDate.format('Do MMMM YYYY');
                } else {
                    this.endDate = '';
                }
            }

Useful for anyone else and my future self ;)

Activity icon

Replied to Flatpickr And Calculate Date Lengths

This is what I had in jquery:

function updateEndDate() {
        var dates = $startDate.selectedDates;

        if (dates.length === 0) {
            return false;
        }

        var duration = $('#duration').val();
        var startDate = moment(dates[0]);
        var endDate = null;

        if (duration.length > 0 && startDate.isValid()) {
            durationInt = duration.replace(/\D/g,'');
            durationKey = duration.includes('years') ? 'y' : 'M';
            endDate = startDate.add(durationInt, durationKey).subtract(1, "days");

            $('#end-date .date').text(endDate.format('Do MMMM YYYY')).parent().fadeIn();
        } else {
            $('#end-date .date').empty();
        }
    }

    var $startDate = $("#start_date").flatpickr({
        dateFormat: 'J F Y',
        onChange: function (selectedDates, dateStr, instance) {
            return updateEndDate();
        }
    });

But I'm moving away from jQuery and want to replicate this working in Vue instead

Activity icon

Started a new Conversation Flatpickr And Calculate Date Lengths

Hi all,

I have a couple of inputs, one uses Flatpickr to select a date, and then the other has a list of tenancy lengths, ranging from 6 months to 5 years.

I want to know how I can calculate the length of these to show when the end date will be? So based on the screenshot, that should show as 24th August 2020, this is what I need to calculate and then show.

Feb
14
1 month ago
Activity icon

Replied to Npm Run Dev Stopped Working.....

You probably were, just me and my stupid eye sight in this case lol

Feb
13
1 month ago
Activity icon

Replied to Npm Run Dev Stopped Working.....

Think I figured it out....

I was referencing Vapor assets, rather than local assets. My bad, ignore me...

Activity icon

Replied to Npm Run Dev Stopped Working.....

Only these

So Vue is detected, but just not updating, even though laravel mix shows it compiled correctly!

Activity icon

Replied to Npm Run Dev Stopped Working.....

Yeah sure does I can see changes, but this is me trying to run dev locally not on any server. I'm using Valet and this use to work a few days ago, but now doesn't for some reason.

Activity icon

Replied to Npm Run Dev Stopped Working.....

Nope not me, I'm certainly in the right folder....

Activity icon

Started a new Conversation Npm Run Dev Stopped Working.....

Hi all,

For some reason running npm run dev shows that it's worked, but when I hard refresh I don't see the changes made in any of the Vue files I've made changes to. What could be the cause of this?