theUnforgiven

theUnforgiven

Web Developer at NRS

Member Since 6 Years Ago

UK

Experience Points
293,690
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
1676
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
293,690 XP
May
30
12 hours ago
Activity icon

Replied to Vue Scroll To Bottom Of Div

Even with this:

var div = document.getElementById("collapse-" + group.id);
div.scrollTop = div.scrollHeight - div.clientHeight;

Then I have on the parent div

<div :id="`collapse-${group.id}`" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">

with the bind ID been unique each time. Again still the list of messages stay at the top.

Activity icon

Replied to Vue Scroll To Bottom Of Div

Yes, I had already tried that option too of:

 var messageDisplay = this.$refs.chat;
messageDisplay.scrollTop = messageDisplay.scrollHeight;

But again to no avail :(

May
29
1 day ago
Activity icon

Replied to Vue Scroll To Bottom Of Div

@bobbybouwmann Yes I tried on the ul and parent div, but still the same doesn't work.

Activity icon

Commented on Prerequisite - Blade Components Explained

@JeffreyWay, can you share your PHPStorm settings?

Activity icon

Started a new Conversation Vue Scroll To Bottom Of Div

Hey all,

Hope everyone is good and still safe....

I have a small issue I can't figure out. I want upon clicking an accordion it expands and shows a chat log.

Code for this is as follows:

<div class="panel-body chat-panel border border-light border-bottom-0">
                        <ul class="list-unstyled">
                            <li class="media" v-for="(conversation,index) in group.messages" :key="index" :class="`collapse-${group.id}`">
                                <i class="far fa-user mr-3 img-thumbnail"></i>
                                <div class="media-body" ref="chat">
                                    <h5 class="mt-0 mb-1">
                                        {{ conversation.user.name }}
                                    </h5>
                                    <p>
                                        {{ conversation.message }}<br />
                                        <small class="text-muted pt-1">{{ human(conversation.updated_at) }}</small>
                                    </p>
                                </div>
                            </li>
                        </ul>
                    </div>

This has a set height on the chat-panel class so upon the user clicking to show this I want the list to scroll to the bottom where the latest message is displayed.

I have tried the following:

this.$refs.chat.scrollIntoView();

// Which the ref is on 
<div class="media-body" ref="chat">

But it fails to scroll, what am I missing or doing wrong?

May
24
6 days ago
Activity icon

Replied to S3 Uploading PDF From HTML

It looks like the

$pdf->output();
$output = $pdf->stream(sha1(now()).'.pdf');

Was incorrect...

So I did the following and works fine and uploads correctly to S3 :)

$fileName = Str::random(13).'.pdf';
$output = $pdf->stream(); // Just needed to be stream rather than output, which outputs to the browser.
$path = 'ast/' . $tenancy->id . '/' . $fileName;
$s3 = Storage::disk('s3');
$s3->put($path, $output, 'public');
Activity icon

Replied to S3 Uploading PDF From HTML

I get Call to undefined method Barryvdh\DomPDF\PDF::setBasePath() @tray2 with your suggestion.

Activity icon

Replied to S3 Uploading PDF From HTML

@tray2 I'll try that out.

The error I'm seeing is like this:

                  Error executing "PutObject" on "https://xxxxx.xxx.amazonaws.com/ast/81/HTTP/1.0%20200%20OK%0D%0ACache-Control%3A%20%20%20%20%20%20%20no-cache%2C%20private%0D%0AContent-Disposition%3A%20inline%3B%20filename%3D%22d1eedb1d138e1a374438948c70411c8a76e3f7ee.pdf%22%0D%0AContent-Type%3A%20%20%20%20%20%20%20%20application/pdf
Activity icon

Replied to S3 Uploading PDF From HTML

Anyone know why and how I can get around this?

May
23
1 week ago
Activity icon

Started a new Conversation S3 Uploading PDF From HTML

Hi all,

Hope everyone as had a good week.

I have a small problem, I can't seem to figure out, so I'm looking for some guidance.

I have this piece of code:

$data = request()->html;
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($data);
$pdf->setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true]);
$pdf->output();
$output = $pdf->stream(sha1(now()).'.pdf');

Which makes a PDF from HTML, but I need to upload to S3 when it outputs, and with the server been on Vapor I can't really upload to 'local' folders.

I have tried:

$path = 'ast/' . $tenancy->id . '/' . $output;
$s3 = Storage::disk('s3');
$s3->put($path, $output, 'public');
$urlPath = Storage::disk('s3')->url($path);

But I get Error executing "PutObject" on ...

Any suggestions would be greatly appreciated.

May
15
2 weeks ago
Activity icon

Replied to Moment JS And Date Formatting

I did as follows:

 if(start.isValid()) {
        let span = this.form.duration; // this is passed from select as a number and all in months
        end = start.add(span, 'M').subtract(1, "days"); // So figured I could use that number and M for months.

        this.tenancyDuration = 'Agreement will end on: ' + end.format('Do MMMM YYYY');
} else {
        this.tenancyDuration = '';
}

Seems to work a treat now.

Activity icon

Replied to Moment JS And Date Formatting

It's cool, I changed the formatting from the flatPickr Vuejs component so now it's showing as a valid moment date.

Activity icon

Replied to Moment JS And Date Formatting

@topvillas - I think i need to format how it comes back from the datepicker, as it's currently 15th May 2020

Activity icon

Started a new Conversation Moment JS And Date Formatting

Hi all,

I'm using Vue for some frontend stuff and I have a Vue Datepicker to select a start date. I thne have a duration box with 6-months 12 months and 18 months.

So I need to get what the end date will be based on selecting a start date and a duration.

So if I selected 1st Jan and 6 months the end dat should return 1st June.

How would one do this in moment as this is my first time using it to this degree.

Apr
29
1 month ago
Activity icon

Replied to SignaturePad And Vapor

Anyone know why this wouldn't work please, I still haven't found a solution

Apr
25
1 month ago
Activity icon

Replied to Event Listener Not Working L7

This appears to have been the problem that it was cached. So artisan cache:clear did the trick.

Activity icon

Replied to Event Listener Not Working L7

This is not been broadcast or any frontend stuff and I have other events and listeners that work, but this one just isn't working.

Activity icon

Started a new Conversation Event Listener Not Working L7

Hi all,

I have and event

<?php

namespace App\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class InvitationSent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $data;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

}

A listener is also provided:

<?php

namespace App\Listeners;

use App\Models\Invitations;
use App\Events\InvitationSent;

class BlockManagementsInvite
{
    /**
     * Handle the event.
     *
     * @param  InvitationSent  $event
     * @return void
     */
    public function handle(InvitationSent $event)
    {        
        Invitations::create([
            'sender_id' => $event->data->sender_id,
            'uuid' => $event->data->uuid,
            'payload' => $event->data->payload
        ]);
    }
}

Both are registered within the EventServiceProvider $listen array

 \App\Events\InvitationSent::class => [
            \App\Listeners\BlockManagementsInvite::class,
        ],

but yet the Invitations::create([ method and listener isn't getting fired.

I can see within Telescope the event is been triggered

The data is also there

But the listener isn't been fired, any reason why this would? FYI I don't see any errors anywhere or in the log file.

Apr
21
1 month ago
Activity icon

Replied to SignaturePad And Vapor

Although this uploads to S3 locally, I've found it's actually storing the file in public/the-file-name.jpg also. So my guess would be the Storage::putFile is wrong or something.

Anyone else fancy chipping in?

Activity icon

Replied to SignaturePad And Vapor

My vapor.yml file as follows:

staging:
        gateway-version: 2
        memory: 1024
        cli-memory: 512
        storage: file-assets
        queue-concurrency: 50
        runtime: php-7.4

Using this works for other uploading, it just seems to be the code I initially posted, that is the problem.

Activity icon

Started a new Conversation SignaturePad And Vapor

Hi all,

I have the following code in my controller:

$imageURI = $request->signature;
$path = 'signatures/'.user()->id;
$outFile = time() . '.jpg';
$output = base64_to_jpeg($imageURI, $outFile);
$file = Storage::putFile($path, $output);
Storage::setVisibility($file, 'public');

This works fine and uploads to S3 fine, but when on staging server which is on Vapor, I get an error: fopen(1587492857.jpg): failed to open stream: Read-only file system Why would this be and how can I overcome it so this works as it does locally?

Apr
19
1 month ago
Activity icon

Replied to Question Regarding Updating On Updated Event

Its cool i wasn’t after a magic solution lol just suggestions of which you provided many so that should help me out. Again greatly appreciated.

Activity icon

Replied to Question Regarding Updating On Updated Event

Yes, I think adding an Id is going to be the only way. So i will pass the uuid and use that i think.

Much appreciate your time buddy. Hope you are well and safe.

Activity icon

Awarded Best Reply on Passing Data To Parent From Child

Finally figured it out....

Set up a Bus.$emit event from the child then in the parent on the created method call that event.

Bus.$on('event-name', (data) => this.doSomething(data));
Activity icon

Replied to Passing Data To Parent From Child

Finally figured it out....

Set up a Bus.$emit event from the child then in the parent on the created method call that event.

Bus.$on('event-name', (data) => this.doSomething(data));
Activity icon

Replied to Passing Data To Parent From Child

I know props are parent > child and for child > parent I could use events, but that would need a button of sort to emit the event, however I only want one button save the whole page.

Activity icon

Replied to Passing Data To Parent From Child

Or would be better to stop importing and put it all within one component?

Activity icon

Started a new Conversation Passing Data To Parent From Child

Hi all,

I have some data in a Fee component (shown below) which is imported in an EditDetails component which is the parent.

My question is, how do I send the data in the screenshot up to the parent when a button is clicked to save on the parent?

Activity icon

Replied to Question Regarding Updating On Updated Event

These are in a files table and theres 13 certificates per property, but when the property info is updated I want to the then update the expiry date within the files table that relates to that certificate. Hope that makes sense :)

Apr
18
1 month ago
Activity icon

Replied to Question Regarding Updating On Updated Event

Its the Files table I need to update as there are 13 files to upload each use a re-usable component in Vue to upload to S3 etc. But then users can update the number and expiry dates as a separate function, so I need to update the files table with these values.

Activity icon

Replied to Question Regarding Updating On Updated Event

@buzzyburrows2 Thanks buddy, I'll check this out, amazing how many times I forget about the $casts property. I'm just sure how it will know what row to update....

Or if I can find a way to pass the UUID to the Vue component this is within too I can then reference it from that I guess, but it currently works as is. It's just the updating I was more interested in.

Activity icon

Started a new Conversation Question Regarding Updating On Updated Event

Hi all,

I hope everyone is well and keeping safe.

I have a small problem I'm hoping one of you lovely people can help trigger what I need to do... The following images show two tables:

// Table - Files

// Table - Properties, but only showing the column I need

My question is the properties -> other_details is saved as JSON and doesn't really carry any ID other than the property ID which is 343 in this case. When the other_details is updated I have an Observer on the updated method, but I need to be able to update the expiry dates from the other_details column to the files table.

As I said as it doesn't really carry any ID other than the property id on both tables, how on earth would I be able to update the relevant column in the files table when other_details is updated?

Apr
16
1 month ago
Activity icon

Replied to File Not Found, Vapor, Vue

The file is getting uploaded to S3 it seems, so not sure why the error is showing and also why it's not setting the files visibility to public.

Any advice/help greatly appreciated.

Activity icon

Started a new Conversation File Not Found, Vapor, Vue

HI all,

I am getting the following error and unable to set the file visibility to public.

I also want it moving from the tmp directory too, which I though this code did:

$replace = str_replace('tmp/', '', $request->input('key'));
$stored = '/uploads/' . user()->id . '/legal/' . $request->input('key');
$moved = Storage::move($replace, $stored);
Storage::setVisibility(str_replace('tmp/', '', $stored, 'public'); //This doesn;'t set to public either

Vue

<form method="post" enctype="multipart/form-data" @submit.prevent="uploadFile">
            <input type="file" name="file" id="file" ref="file">
            <button type="submit" class="btn btn-sm btn-outline-success">Upload</button>
            <div class="mt-3 mb-3" v-if="uploadProgress">
                <span class="alert alert-success">Upload Complete</span>
            </div>
        </form>

Then the method within Vue:

uploadFile() {
            Vapor.store(this.$refs.file.files[0], {
                progress: progress => {
                    setTimeout(() => {
                        this.uploadProgress = Math.round(progress * 100);
                    }, 1000);
                }
            }).then(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,
                    url: response.url,
                    optional: this.optional,
                    property_id: this.property_id,
                });
                setTimeout(() => {
                    swal({
                        title: 'Success!',
                        text: 'File successfully uploaded and saved.',
                        icon: 'success',
                        button: 'Continue',
                    });
                }, 1300); 
                this.uploadProgress = false;   
            });
        }
Activity icon

Replied to How To Get Values From Db On Component Creation And Like Laravel's Old Method.

Yes using a button is easy, but this as to be on mounted to get the value as they will be more than one hence why I think the ID is needed, but again this needs to be mounted. So there won't be a trigger as such to get that.

Activity icon

Replied to How To Get Values From Db On Component Creation And Like Laravel's Old Method.

I'd still wish to know how to do this with the v-toggle button if anyone feels like chiming in

Apr
15
1 month ago
Activity icon

Replied to How To Get Values From Db On Component Creation And Like Laravel's Old Method.

@tykus - As it's within a for loop, I'm not sure how I can pass the id in order to get the relevant record form the db within a mounted or created method, it's easy with a @click event or something, but can't for the life of me figure this out

Activity icon

Replied to How To Get Values From Db On Component Creation And Like Laravel's Old Method.

Great thanks @tykus Thats what I thought I needed to do, just wasn't 100%.

Has for the ID thing, I have this:

<toggle-button 
                        		v-model="wantsNotify" 
                        		:value="false"
                        		:sync="true"
                        		:labels="{checked: 'Yes', unchecked: 'No'}"
                        	/>

From https://www.npmjs.com/package/vue-js-toggle-button

Which is inside a for loop, so it's a toggle button, basically I want to get it's attribute from the database 0 for unchecked 1 for checked again on created or mounted, then the v-model wantsNotify will updated on change. Question is how do I pass the ID to this?

Here's the full for loop

<tr v-for="(membership, index) in memberships" :key="index">
                        <td>{{ membership.name }}</td>
                        <td>{{ membership.number }}</td>
                        <td>{{ getHumanDate(membership.expiry) }}</td>
                        <td>
                        	<toggle-button 
                        		v-model="wantsNotify" 
                        		:value="false"
                        		:sync="true"
                        		:labels="{checked: 'Yes', unchecked: 'No'}"
                        	/>
                        	<input type="checkbox" v-model="wantsNotify">
						</td>
                        <td>{{ '£' + parseFloat(membership.cost).toFixed(2) }}</td>
                        <td v-if="membership.expiry ">
							<button @click="renew(membership.id)" class="btn btn-sm btn-outline-primary">Renew</button>
                        </td>
                    </tr>

Activity icon

Replied to How To Get Values From Db On Component Creation And Like Laravel's Old Method.

So if mounted or created, do a get request, then just update the modal attributes from the get request?

But what about getting an ID from a single row etc?

Activity icon

Started a new Conversation How To Get Values From Db On Component Creation And Like Laravel's Old Method.

Hi all,

I'm just not 100% on how to get values from the db and then fill them out on forms, like you would do with PHP/Laravel, how best can this be done and roughly how in Vue?

Like select boxes, checkboxes and normal inputs.

Help greatly appreciated.

Activity icon

Replied to Opening Times W/Vue

Anyone have any advice on how best to achieve such task...?

Apr
14
1 month ago
Activity icon

Started a new Conversation Opening Times W/Vue

Hi all,

I hope everyone is well....

I'm using Vuejs and Laravel and I have a bunch of selects from Monday to Sunday AM & PM times for opening hours, but I'm struggling to think how best to do this and add each value of the AM & PM values of each day to an array so I can save it to the database.

I have the following in my data obj:

data () {
		return {
			am: [
				'6:00','6:30','7:00','7:30','8:00','8:30','9:00','9:30','10:00','10:30','11:00','11:30','12:00'
			],
			pm: [
				'12:00','12:30','13:00','13:30','14:00','14:30',
                '15:00','15:30','16:00','16:30','17:00','17:30','18:00','18:30','19:00','19:30','20:00','20:30','21:00','21:30','22:00'
			],
			opening_hours: [],
		}
	},

Just to return arrays of AM and PM hours....

Then I have the following for Monday at present, but here's where I'm stuck at:

<div class="col-md-3">Monday</div>
                <div class="form-group col-md-2">
                    <select v-model="opening_hours[monday_am]" class="form-control inputs" @change="updateHour">
	                    <option value="">Please Select</option>
	                    <option v-for="(a, index) in am" :key="index" :value="a">
							{{ a }}
	                    </option>
                    </select>
                </div>

                <div class="form-group col-md-2">
                    <select v-model="opening_hours[monday_pm]" class="form-control inputs" @change="updateHour">
                    	<option value="">Please Select</option>
                    	<option v-for="(p, index) in pm" :value="p" :key="index">
							{{ p }}
	                    </option>
                    </select>
                </div>

So if I select 06:00 for am and 15:00 for PM I want this to be Monday_06:00-15:00 or something so I can save that to the db.

Apr
11
1 month ago
Activity icon

Replied to A Number Given, Split Into A Foreach

Of course, apologies.

Activity icon

Replied to A Number Given, Split Into A Foreach

Great, nice couple of options there, I went with @tray2 suggestion and works perfect.

Thanks again both for your time and suggestions, greatly appreciated.

Activity icon

Replied to A Number Given, Split Into A Foreach

Sweet, yeah think that will work.

Much appreciated guys, thank you.

Activity icon

Replied to A Number Given, Split Into A Foreach

Anything up to about 150, when you say a simple for and duplicate the N times, how? sorry had a few days off and just trying to quick whip something up over the weekend now.

Activity icon

Replied to A Number Given, Split Into A Foreach

Yeah open to any suggestion, just not sure how to achieve it, as a foreach won't work as it's just a number and there's no index or anything, so the user passes the number i.e 10, then that amount of rows inserted into the db.

Activity icon

Replied to A Number Given, Split Into A Foreach

This is real data from a form, then I need to add those rows in the database based on what number they provided

Activity icon

Started a new Conversation A Number Given, Split Into A Foreach

Hi all,

I hope everyone is safe and well....

If a user passes a number say 10 I want to insert that amount of rows into the database, how best to achieve this without complex code?

Apr
07
1 month ago
Activity icon

Replied to Passing Index To Child Vue

Ah, thanks Ryan. That's the one bloody bind or not to bind always confuses me lol