theUnforgiven

theUnforgiven

Web Developer at NRS

UK

Member Since 4 Years Ago

Experience Points 259,810
Experience
Level
Lessons Completed 1405
Lessons
Completed
Best Reply Awards 45
Best Answer
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.

14 Dec
22 hours ago

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

It does seem to be $reading->meter_type = $types[$i]; that was the problem. Commented this out and it works.

:(

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

For the Types I do have

<option v-for="(type, index) in reading_type" 
               :value="type.tags"
               :key="type.index" 
               :id="type.id"
>
    {{ type.value }}
</option>

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

Not validating any data so that wouldn't be a factor and those fields in question are just really "hard-coded" with the Vue template

<div class="row mt-2">
                        <div class="col">
                        <label>Gas Reading</label>
                        <input type="number" name="reading[0][0]" class="form-control">
                   
                        <label>Water Reading</label>
                        <input type="number" name="reading[0][1]" class="form-control">
                    
                        <label>Electric Reading</label>
                        <input type="number" name="reading[0][2]" class="form-control">
                    </div>
                    <div class="col">
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[0][0]">
                
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[0][1]">
                    
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[0][2]">
                    </div>

as you can see edited to be reading[0][0] etc

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

I remember trying such thing this morning, and gives preg_match() expects parameter 2 to be string, array given error.

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

Ok, so how does one get that to work?

theUnforgiven left a reply on Multidimensional Array From Vue To Laravel

Hmmm, still shows as message: "Undefined offset: 2"

theUnforgiven started a new conversation Multidimensional Array From Vue To Laravel

I'm having a bit of brain freeze and can't figure out how to get the data from these two forms from VueJS to save with Laravel.

Here's the code with VueJS

<label>Reading Type</label>
<select name="reading_type[]" class="form-control">
    <option value="">Please Select</option>
    <option v-for="(type, index) in reading_type" 
            :value="type.tags"
            :key="type.index" 
            :id="type.id"
    >
        {{ type.value }}
    </option>
</select>
<div class="row mt-2">
    <div class="col">
        <label>Gas Reading</label>
        <input type="number" name="reading[]" class="form-control">

        <label>Water Reading</label>
        <input type="text" name="reading[]" class="form-control">

        <label>Electric Reading</label>
        <input type="number" name="reading[]" class="form-control">
    </div>
    <div class="col">
        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[]">

        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[]">

        <label>Reading Date</label>
        <input type="date" class="form-control" name="reading_date[]">
    </div>
</div>

Here's what I have currently with Laravel:

$readings = $request->get('reading');   
$dates = $request->get('reading_date');
$types= $request->get('reading_type');

for($i = 0; $i < $readings; $i++){
    $reading = new MeterReadings;
    $reading->user_id       = user()->id;
    $reading->entered_by    = user()->name;
    $reading->meter_type    = $types[$i];
    $reading->property_id   = $request->property;
    $reading->reading       = $readings[$i];
    $reading->reading_date  = $dates[$i];
    $reading->save();
}

But it's not saving or throwing some errors like Undefined offset: 2

within Vue I send a post request like so:

addReading: function() {
        let readingForm = document.getElementById('readingForm');
        let formData = new FormData(readingForm);

        axios.post('/api/addReadings/', formData);
}

If I dd() the request I get the full request:

array:4 [
  "property" => "161"
  "reading_type" => array:2 [
   0 => "moved_out"
   1 => "move_in"
 ]
 "reading" => array:6 [
    0 => "001"
   1 => null
   2 => null
   3 => "002"
   4 => null
   5 => null
 ]
"reading_date" => array:6 [
  0 => "2018-12-12"
  1 => null
  2 => null
  3 => "2018-12-13"
  4 => null
  5 => null
 ]
]

Any help/advice to get these to save as individual rows would be awesome, sorry it's a lame question, just having a really bad brain freeze and it's been one of them weeks, so help greatly appreciated.

theUnforgiven left a reply on Within Foreach Loop

Figured it out by adding and ID to the form element, then added the following to the method:

let readingForm = document.getElementById('readingForm');
let formData = new FormData(readingForm);

theUnforgiven left a reply on Within Foreach Loop

I'm still hitting a wall here, looking for some advice on this, new to the updated VueJS version and not worked with it for a long time so I'm a little stuck.

13 Dec
1 day ago

theUnforgiven started a new conversation Within Foreach Loop

If there's more than 1 record returned from the axios call, it shows two of the following code:

<div class="col" v-for="tenancy in tenancies">               
                    <div class="alert alert-warning">
                        <h5>Tenancy Details</h5>
                        <ul class="list-unstyled">
                            <li>Ref No: {{ tenancy.ref_no }}</li>
                            <li>Tenant: {{ tenancy.tenant.name }}</li>
                            <li>Start Date: {{ tenancy.tenancy_start | formatDate }}</li>
                            <li>End Date: {{ tenancy.tenancy_end | formatDate }}</li>
                        </ul>
                    </div>
                    <label>Reading Type</label>
                    <select name="reading_type" class="form-control">
                        <option value="">Please Select</option>
                        <option value="move_in">Moving In Reading</option>
                        <option value="mid_term">Mid-Term Reading</option>
                        <option value="moved_out">Moving Out Reading</option>
                    </select>
                    <div class="row mt-2">
                        <div class="col">
                        <label>Gas Reading</label>
                        <input type="number" name="reading[gas]" class="form-control">
                   
                        <label>Water Reading</label>
                        <input type="text" name="reading[water]" class="form-control">
                    
                        <label>Electric Reading</label>
                        <input type="number" name="reading[electric]" class="form-control">
                    </div>
                    <div class="col">
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[gas]">
                
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[water]">
                    
                        <label>Reading Date</label>
                        <input type="date" class="form-control" name="reading_date[electric]">
                    </div>
                </div>

So my question is how do I get the data from each one.

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

No that didn't work, but this does:

getReadings: function() {

            let reading = this;

            axios.get('/api/meter-reading/result/' + this.propertyId)
                .then(function (data) {
                    reading.tenancies = data.data;
                });
        },

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

The componant is above i havent changed it only the ‘then’ fucntion on the call

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

I see, i’ll try that, tha k you very much. ?

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

Anyone, have any more suggestions on this please?

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

Anyone, have any more suggestions on this please?

12 Dec
2 days ago

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

This is what is the output is from the JSON call I make when viewing console

(2) [{…}, {…}]
0: {id: 124, ref_no: "TN09102149", property_id: 161, agency_id: null, landlord_id: 61, …}
1: {id: 125, ref_no: "TN09102150", property_id: 161, agency_id: null, landlord_id: 61, …}
length: 2
__proto__: Array(0)

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

Yes, thought I'd tried this and I get

Uncaught (in promise) TypeError: Cannot read property 'data' of undefined

theUnforgiven left a reply on Vue, OnChange, Foreach Loop, Display With New Html Elements

Thank you, i will give that a try, although i’m pretty sure i did try that and got the same response.

theUnforgiven started a new conversation Vue, OnChange, Foreach Loop, Display With New Html Elements

Hi all,

I'm struggling a little trying to get the following to work.....

So basically I have a select which upon user selection it gets the ID of the record, which works fine. But upon this I want to loop through each record get certain bits of data and put within html elements on the same page.

Here's what I have currently:

// Vue File:

<template>
    <div>
        <select name="property" class="form-control" v-model="propertyId" @change="getReadings">
            <option value="">Please Select</option>
            <option v-for="(property, index) in properties" 
                    :value="property.id"
                    :key="property.index" 
                    :id="property.id"
            >
                {{ property.name_number }} {{ property.street }}, {{ property.town }}, {{ property.postcode }}
            </option>
        </select>
    </div>
</template>

<script>
export default {

    name: 'TenancyMeterReading',

    props: ['properties'],

    data: () => {
        return {
            propertyId: '',
            tenancies: {}
        }
    },

    methods: {
        getReadings: function() {
            axios.get('/api/meter-reading/result/' + this.propertyId)
                .then(function(response) {

                    for (let tenancy = response.data; tenancy > response.length; i++) {

                        this.tenancies = tenancy[i]
                    }
                }).catch(function(error) {
                    console.log(error.response.data);
                });
               
        },

        addReading: function() {

        }
    }

}
</script>

<style>

</style>

// Blade file
<meter-reading :properties="{{ $properties }}"></meter-reading>

Here's the Vue Tools showing:

Any help/advice greatly appreciated,

04 Dec
1 week ago

theUnforgiven left a reply on Laravel Calendar Add Event On Fly

What have you tried?

23 Nov
3 weeks ago

theUnforgiven left a reply on Bootstrap Typeahead Select

Ok, cool. I'll check this out. Thanks dude :)

theUnforgiven left a reply on Bootstrap Typeahead Select

Will have a look at this thanks, but surely $('#quick_search_name').val(''); would just get the value from what is typed rather than what is shown from the autocomplete?

theUnforgiven left a reply on Bootstrap Typeahead Select

Anyone else encountered this problem and how did you fix?

theUnforgiven started a new conversation Bootstrap Typeahead Select

Hi all,

I can't seem to get my code to work so when a user selects from the autocomplete it enters into the input.

Heres the code:

// JS

let path = "{{ url('search/landlord') }}";

$('#search').typeahead({
    minLength: 3,
    source:  function (query, process, ) {
        return $.get(path, { query: query }, function (data) {
            return process(data);
        });
    },
    select: function( ui, item ) {
        console.log(item); 
    }
});


// HTML

<input type="text" class="form-control" name="term" id="search" placeholder="Start typing something to search..." data-provide="typeahead" autocomplete="off">


Both console.log(item); and console.log(ui); shows as undefined... Any suggestions on whats wrong or what I may have missed.

16 Nov
4 weeks ago

theUnforgiven left a reply on Cloning Rows, But....

@makis - Thanks for this, I'll give this a try also.

14 Nov
1 month ago

theUnforgiven left a reply on Cloning Rows, But....

Hmm yes good point, how does one make it unique?

theUnforgiven left a reply on Cloning Rows, But....

Ok so I added this:

jQuery(document).on('change', '.tenants', function(e) {
    let tenant = $(".tenants").val();

    $.ajax({
        type: 'GET',
        url: '/api/tenant/right-to-rent/' + tenant,
        success: function (data) {
            if(data.status == 1) {
                $("#r2r").html('<div class="alert alert-success table-alert">Completed</div>');
            }
            else {
                $("#r2r").html('<div class="alert alert-danger table-alert">Incomplete</div>');
            }
        },
        error: function () {
            console.log('An error occurred.');
        }
    });
});

Which kinda works, but copies the top row and then when you select on the 3rd row it inputs the alert on row 1.

13 Nov
1 month ago

theUnforgiven left a reply on Cloning Rows, But....

I hear ya @cronix i will that a read and try it out. Thanks

theUnforgiven left a reply on Cloning Rows, But....

Yes so if i press add new row then it inserts the row fine, but then selecting another user the ajax call doesnt fire

theUnforgiven left a reply on Cloning Rows, But....

Apologies, I did forgot to post the form, so here it is.

I want the new row to have a unique ID as you say sharing the same ID won't work obviously.

Form:

<table class="table table-sm" id="tenancy-table">
                                        <thead>
                                            <tr>
                                                <th colspan="2" class="text-center">Tenant(s)</th>
                                                <th class="text-center">Lead</th>
                                                <th class="text-center">Relationship</th>
                                                <th class="text-center">Paying Rent</th>
                                                <th class="text-center">Amount</th>
                                                <th class="text-center">Paying Deposit</th>
                                                <th class="text-center">Amount</th>
                                                <th class="text-center">TAP or Non TAP</th>
                                                <th class="text-center">Right to Rent</th>
                                                <th class="text-center">R2R Checked</th>
                                                <th></th>
                                            </tr>
                                        </thead>

                                        <tbody>
                                            <tr id="clone">
                                                <td colspan="2" class="text-center">
                                                    <select name="tenants" class="form-control tenants" id="tenants" style="width: 160px;">
                                                        <option>Select Tenant</option>
                                                        @foreach($tenants as $tenant)
                                                        <option value="{{ $tenant->uuid }}">{{ $tenant->name }}</option>
                                                        @endforeach
                                                    </select>
                                                </td>
                                                <td class="text-center"><input type="checkbox" name="lead_tenant" value="1"></td>
                                                <td class="text-center">
                                                    <select name="relationship" class="form-control">
                                                        <option value="family">Family</option>
                                                        <option value="friend">Friend</option>
                                                        <option value="spouse">Spouse</option>
                                                        <option value="child">Child</option>
                                                        <option value="other">Other</option>
                                                    </select>
                                                </td>
                                                <td class="text-center">
                                                    <select name="rent_paying" style="width: 100px;" class="form-control">
                                                        <option value="">---</option>
                                                        <option value="yes">Yes</option>
                                                        <option value="no">No</option>
                                                    </select>
                                                </td>
                                                <td class="text-center">
                                                    <input type="text" name="rent_contribution" style="width: 100px;" class="form-control">
                                                </td>
                                                <td class="text-center">
                                                    <select name="deposit_paying" style="width: 100px;"class="form-control">
                                                        <option value="">---</option>
                                                        <option value="yes">Yes</option>
                                                        <option value="no">No</option>
                                                    </select>
                                                </td>
                                                <td class="text-center"><input type="text" name="deposit_contribution" style="width: 100px;" class="form-control"></td>
                                                <td class="text-center">
                                                    <select name="tap" class="form-control">
                                                        <option value="">---</option>
                                                        <option value="Accredited Tenant">Accredited</option>
                                                        <option value="Accreditation Pending">Pending</option>
                                                        <option value="Not Accredited">No Accreditation</option>
                                                    </select>
                                                </td>
                                                <td id="r2r"></td>
                                                <td>
                                                    <select name="tap_checked" class="form-control">
                                                        <option value="">---</option>
                                                        <option value="yes">Yes</option>
                                                        <option value="no">No</option>
                                                    </select>
                                                </td>
                                            </tr>
                                           
                                        </tbody>
                                    </table>

theUnforgiven left a reply on Cloning Rows, But....

Anyone have a suggestion to this please.

theUnforgiven started a new conversation Cloning Rows, But....

Hi all,

I have a form and a button of which I clone the row, however this all works fine; but I have a select to select a user. Upon selection it's sends an ajax request to get their status.

This works fine on the first row, but any additional rows it doesn't, so by the code below, how can I get this to work as I need to?

// Clone Script
$("#addRow").click(function(e) {
        e.preventDefault();
        var x = 0;
        x++;
        // Clone form-group
        var clone = $("#clone").clone();
        // Update name attribute of all input elements in the group:
        $('[name]', clone).each(function(){
            var $this = $(this);
            clone.find("input").val("");
            $("#r2r").empty();
            $this.attr('name', $this.attr('name') + '_' + x);
        });
        // Append clone to the form
        clone.appendTo($('#tenancy-table'));
        x++;
    });


// Ajax Call
$(".tenants").on('change', function() {

        let tenant = $(".tenants").val();

        $.ajax({
            type: 'GET',
            url: '/api/tenant/right-to-rent/' + tenant,
            success: function (data) {
                if(data.status == 1) {
                    $("#r2r").html('<div class="alert alert-success table-alert">Completed</div>');
                }
                else {
                    $("#r2r").html('<div class="alert alert-danger table-alert">Incomplete</div>');
                }
            },
            error: function () {
                console.log('An error occurred.');
            }
        });
    });

Thanks in advance ;)

12 Nov
1 month ago

theUnforgiven left a reply on Getting The Name Of Files In Multi Upload

Hi guys, I want to get the expiry date value also now within this array and within the form I have same as above but with an added element of:

<input id="epc-expiry" type="text" placeholder="Pick a date" class="form-control" value="{{ old('energy_expiry', $property->expiry_date) }}" name="file[energy_expiry]">

So how can I get the energy_expiry value also?

07 Nov
1 month ago

theUnforgiven left a reply on Please Bring Back The Older Laracasts Design

Stuff all the "haters" this is far the best Laracasts design I have seen and I remember the very 1st design.... A Job well done @jeffreyway ;)

theUnforgiven left a reply on What About New Look @laracast.com

Tailwind, if you look at some of the videos of the past few weeks, Jeff shows us that he's using Tailwind.

theUnforgiven left a reply on Upgraded To Mojave, Homestead Not Working

Not a solution or a answer to your question, but have you tried Laravel Valet instead?

theUnforgiven left a reply on What About New Look @laracast.com

Really well presented, nice color scheme and looks the bomb!

30 Oct
1 month ago

theUnforgiven left a reply on Getting The Name Of Files In Multi Upload

Yeah of course it is, how dumb am I, been one of those days today I tell ya

theUnforgiven left a reply on Getting The Name Of Files In Multi Upload

Yeh I got that already, but I want to get the file[co2] part

theUnforgiven started a new conversation Getting The Name Of Files In Multi Upload

Hi all,

I have a form which as enctype="multipart/form-data" then each one is "named" as you can see below:

 <div class="col-xs-12 col-md-4">
                                <div class="form-group">
                                    <label class="label-control" for="epc-energy">Energy Certificate</label>
                                    <input id="epc-energy" type="file" class="form-control" name="file[energy]">
                                    <br />
                                    <a href="http://epc.rightmove.co.uk/epcgenerator" class="btn btn-primary" target="_blank">Get your EPC Certificate</a>
                                </div>
                            </div>

                            <div class="col-xs-12 col-md-4">
                                <div class="form-group">
                                    <label class="label-control" for="epc-co2">CO2 Certificate</label>
                                    <input id="epc-co2" type="file" class="form-control" name="file[co2]">
                                </div>
                            </div>

But How within this block of code do I get the file name i/e energy or co2


$files = $request->file('file');
            
foreach ($files as $file) {
    // how within this foreach do I get the name?
}   

$file['file'] or $file['file']['name'] throws an error.

29 Oct
1 month ago

theUnforgiven left a reply on Signature Pad

Then you should have something along these lines in a JS file


$( function() {
    
    var signaturePad = new SignaturePad(document.getElementById("signature-pad"), {
          backgroundColor: 'rgba(255, 255, 255, 0)',
          penColor: 'rgb(0, 0, 0)'
    });

    var saveButton = document.querySelector('.btn-save');
    var clearButton = document.querySelector('[data-action=clear]');

    saveButton.addEventListener('click', function (e) {
        document.querySelector('[name=signature_data]').value = signaturePad.toDataURL('image/png', 100);
    });

    clearButton.addEventListener('click', function () {
        signaturePad.clear();
    });
   
    var form = $('#sign_form');

    $(saveButton).click(function() {
        $.ajax({
            url: form.attr( 'action' ),
            data: form.serialize(),
            type: 'POST',
            success: function(response, ui) {
                swal({
                  title: "Signature Saved",
                  text: "Your signature has now been stored.",
                  icon: "success",
                });
                window.setTimeout(function(){window.location.reload()}, 3000);
            },
            error: function(response) {
                console.log('Error!');
            }
        });
    });
});

theUnforgiven left a reply on Signature Pad

You should have something like this:

<div>
                        <div class="digital-signature">
                            <div class="form-group">
                                <canvas id="signature-pad" class="signature-pad" width="7500" height="400"></canvas>
                            </div>
                        </div>

                    </div>

                    <div class="form-group">
                        <input type="hidden" id="signature_data" name="signature_data" class="form-control" value="">
                    </div>

theUnforgiven left a reply on Signature Pad

Whats your actual form look like from your blade file?

theUnforgiven left a reply on Signature Pad

@lawkunchi How are you passing the data uri to the form?

26 Oct
1 month ago

theUnforgiven left a reply on Signature Pad

@lawkunchi - Sorry I'm a little tied up at the minute, feel free to see the above posts on what I did and also post what you have so far on here and I'll try and help.

23 Oct
1 month ago

theUnforgiven left a reply on Just Published My Laravel Project And Vue Is Not Working

did you register the component correctly? was this working when developing? have you run npm install on your server?

18 Oct
1 month ago

theUnforgiven left a reply on Add Variables To PDF

Anyone else have any ideas/suggestions?

17 Oct
1 month ago

theUnforgiven left a reply on Add Variables To PDF

Anyone else have any ideas?

theUnforgiven left a reply on Add Variables To PDF

It starts off as

<p class="ft01" style="margin: 0; padding: 0; font-size: 13px; font-family: Times; color: #000000; position: absolute; top: 236px; left: 85px; white-space: nowrap;">Date: <?php echo date('d-m-Y'); ?></p>
<p class="ft01" style="margin: 0; padding: 0; font-size: 13px; font-family: Times; color: #000000; position: absolute; top: 288px; left: 85px; white-space: nowrap;">This agreement is between us:  {{ $omeVar }}</p>

Then does the above to get rendered.

theUnforgiven left a reply on Add Variables To PDF

I have shown this above, where I added the date is how it's parsed, on which I save this to the db, then second code is what is used to render this.