theUnforgiven

theUnforgiven

Member Since 4 Years Ago

UK

Web Developer at NRS

Experience Points 265,490
Experience Level 50

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 1454
Lessons
Completed
Best Reply Awards 45
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

19 Mar
6 days ago

theUnforgiven left a reply on For Loop With Dates

@grenadecx solution worked a treat, so I've opted for that. Both I'd like to thank for these suggestions.

theUnforgiven left a reply on For Loop With Dates

Thanks guys, that should give me enough ideas on how best to do this now, much appreciated ;-)

theUnforgiven left a reply on For Loop With Dates

So within the return statement I guess I can add the following: ??

$rents = new RentDetails;
$rents->user_id = $tenant->id;
$rents->landlord_id = user()->companies->first()->id;
$rents->property_id = $property->id;
$rents->item = 'rent';
$rents->amount = $property->rent;
$rents->amount_paid = 0;
$rents->due_date = ''; // this is where the date should be the set due date then plus 1 month thereafter
$rents->paid = 0;
$rents->part_paid = 0;
$rents->upaid = 1;
$rents->paid_date = null;
$rents->month = '';
$rents->paid_to = '';
$rents->save();

theUnforgiven started a new conversation For Loop With Dates

Hi all,

I hope everyone is having a good week so far....

I'm looking for some help from you awesome people, I want to have a number of rows entered into the database, based on the selection from a user.

For Example:

So if the user selects 6 month, then I want to enter 6 rows with the first row due date been the due date that is set, then the remaining 5 rows be due date plus 1 month.

Like wise if it's 12 month, 2 year etc

I have the following switch statement, which strips out a - and everything after it so in essence just words and this gives me the number.

$duration = strstr($request->input('duration'), '-', true);
        switch ($duration) {
            case 6: // 6mth
                $os_payments = 6;
                break;
            case 12: //12 mth
                $os_payments = 12;
                break;
            case 18: // 18 mth
                $os_payments = 18;
                break;
            case 2: // 2 yr
                $os_payments = 24;
                break;
            case 3: // 3 yr
                $os_payments = 36;
                break;
            case 4: // 4 yr
                $os_payments = 48;
                break;
            case 5: //5 yr
                $os_payments = 60;
                break;
        }

Which then I have the amount of months, but I can't seem to do a for loop for this, to enter the correct amount of rows and the due dates like I mentioned above.

Any help, greatly appreciated.

04 Mar
3 weeks ago

theUnforgiven left a reply on Creating Foreign Key In Laravel 5.8.2 Failling

I found the same issue and just changed bigInteger to integer

21 Feb
1 month ago

theUnforgiven left a reply on Selecting Checkboxes With VueJS Chat

By adding an extra method to the component with help from @RachidLaasri

selectUser(userId) {
                if(this.selected.includes(userId)) {
                    return this.selected.remove(userId);
                }
                this.selected.push(userId);
            },

This is now working.

theUnforgiven left a reply on Selecting Checkboxes With VueJS Chat

Anyone willing to help

theUnforgiven left a reply on Selecting Checkboxes With VueJS Chat

Anyone willing to try and help a brother out?

theUnforgiven left a reply on Selecting Checkboxes With VueJS Chat

Just a pointer too, the current code is saving all 3 users I have associated with the company rather than what is selected.

theUnforgiven started a new conversation Selecting Checkboxes With VueJS Chat

Hi all,

I have a small problem with a chat application I'm building.

I have a method like this:

getEveryone(event) {
                axios.get('/chat/users/' + this.property)
                    .then((response) => {

                        let user_groups = response.data;
                        user_groups.map((user_groups) => {
                            console.log(user_groups);
                            this.users.push(user_groups);
                        });
                    });
            },

Which is a get request to get users associated with a company but it's no longer showing the user etc, and before it did work and I could select a user, but it wouldn't store the IDs of multiple users.

I have the following store method on my controller that is responsible for this:

public function store()
    {
        $group = Group::create(['name' => request('subject'), 'subject' => request('subject')]);

        $users = collect(request('users'));
        $users->push(auth()->user()->id);
        $group->users()->attach($users->pluck('id'));

        broadcast(new GroupCreated($group))->toOthers();
        return $group;
    }

I have the following with the template:

<div class="form-check" v-model="users" v-for="(user, index) in users" :key="index">
                        <input class="form-check-input" type="checkbox" id="inlineCheckbox1" :value="user.id" >
                        <label class="form-check-label" for="inlineCheckbox1">{{ user.name }} <span class="text-dark">({{ user.account_type | capitalize }})</span></label>
                    </div>

Then also the method to store the new chat group

createGroup() {
                axios.post('/groups', {subject: this.subject, users: this.users})
                    .then((response) => {
                        this.subject = '';
                        this.selected = [];
                        Bus.$emit('groupCreated', response.data);

                        location.reload();
                });
                location.reload();
            }

As you can see from this screen shot the creating of a group is the problem:

I believe looking at the package I'm using https://github.com/viraj-khatavkar/group-chat-app-laravel-pusher the group creation should just be a bunch of IDs as it's a pivot table. But I've been trying to resolve this for the past 2 days, to no avail; so looking to this awesome community to help a brother out ;)

12 Feb
1 month ago

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

I can't use axios in this case as I said the component is wrapped with the form tag anyhow and I save all the data at the same time.

11 Feb
1 month ago

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

@realrandyallen so what you are saying is not wrong, but not what I require.

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

The vue component is part of the form, but I want the Vue component to be responsible for adding new rows and such, then save these values.

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

Apologies, I should have mentioned that the vue view is within a regular form tag as follows, as there's more stuff I collect and save on the same page:

<form method="POST" action="{{ route('company.profile.edit', $company) }}" enctype="multipart/form-data">

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

How would I then get the parsed computed into my request obj?

theUnforgiven left a reply on Help With Name Field W/VueJS Saving As Array?

Sure

<template>
    <div>
        <div v-for="(input, index) in inputs" :key="index">
            <div class="row">
                <div class="col">
                    <div class="form-group">
                        <input type="text" 
                            class="form-control" 
                            :id="input.id" 
                            v-model="input.item" 
                            :name="'fees['+index +input.item+']'"
                            placeholder="Enter any new fees here"
                        >
                    </div>
                </div>

                <div class="col">
                    <div class="form-group">
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                              <div class="input-group-text">£</div>
                            </div>
                            <input type="number" 
                                class="form-control" 
                                placeholder="0.00" 
                                :id="input.id" 
                                v-model="input.amount" 
                                :name="'fees['+index + input.amount+']'"
                            >
                            <button v-on:click.prevent="removeInput(input.id)" 
                                    class="btn btn-sm btn-danger">
                                    <i class="fa fa-trash"></i>
                            </button>
                        </div>   
                    </div>
                </div>
            </div>
        </div>
        
        <button class="btn btn-sm btn-outline-secondary mt-1 mb-3" @click="addInput">Add new fee</button>
    </div>
</template>

<script>

    export default {

        data() {
            return {
                counter: 0,
                inputs: [{
                    id: '',
                    item: '',
                    amount: '',
                    value: ''
                }],
            }
        },

        methods: {
            addInput(e) {
                e.preventDefault();
                this.inputs.push({
                    id: `item${++this.counter}`,
                    item: '',
                    amount: '',
                    value: ''
                });
            },
            removeInput : function (input) {
                this.inputs.splice(input, 1);
            }
        }
    }

</script>

Basically it adds new rows, so the name fields I want to be like I explain within the array above when I save the data from my Laravel controller

theUnforgiven left a reply on Help With Name Field Within A Form W/VueJS

Anyone, willing to help out please, I know it's something simple I'm missing

theUnforgiven left a reply on Help With Name Field Within A Form W/VueJS

Can anyone shed any light on this please?

10 Feb
1 month ago

theUnforgiven left a reply on Help With Name Field Within A Form W/VueJS

Anyone, willing to help out please, I know it's something simple I'm missing

09 Feb
1 month ago

theUnforgiven left a reply on Help With Name Field Within A Form W/VueJS

I have just tried the following: :name="'fees['+index + input.item+']'"

But that results in

 "fees" => array:5 [▼
    "admin" => "10.00"
    "reminder" => "40.00"
    "bank" => "50.00"
    "0qwerty" => "qwerty"
    "0123" => "123"
  ]

Which is still not right like I said it should be "qwerty" => "123"

theUnforgiven started a new conversation Help With Name Field Within A Form W/VueJS

I have the following form in a Vue file:

<div v-for="(input, index) in inputs" :key="index">
            <div class="row">
                <div class="col">
                    <div class="form-group">
                        <input type="text" 
                            class="form-control" 
                            :id="input.id" 
                            v-model="input.item" 
                            placeholder="Enter any new fees here"
                        >
                    </div>
                </div>

                <div class="col">
                    <div class="form-group">
                        
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                              <div class="input-group-text">£</div>
                            </div>
                            <input type="number" 
                                class="form-control" 
                                placeholder="0.00" 
                                :id="input.id" 
                                v-model="input.amount" 
                            >
                            <button v-on:click.prevent="removeInput(input.id)" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to remove this?')"><i class="fa fa-trash"></i></button>
                        </div>   
                    </div>
                </div>
            </div>
        </div>

Once the form is submitted I want to have name values like this is from another element within the same form. Basically add to this array with what the user types in the first input and then the fee amount in the amount field.

 "fees" => array:4 [▼
    "admin" => "10.00"
    "reminder" => "40.00"
    "bank" => "50.00"
  ]

I did try :name="'fees[' + input.item + ']'" but this results in:

"fees" => array:5 [▼
    "admin" => "10.00"
    "reminder" => "40.00"
    "bank" => "50.00"
    "new item" => "new item" // wrong
    0 => "99" // wrong
    // should be 
    "new item" => "99"
  ]

Can anyone help me on what the name field should be please J

24 Jan
2 months ago

theUnforgiven left a reply on Pivot Data On Query

Yes I just realised this hehe

theUnforgiven left a reply on Pivot Data On Query

I get Trying to get property of non-object on line 19 which responds to $query->where('id', '<>', $auth_user->company->id);

Based on:

$auth_user = user(); //auth()->user();
    return User::orderBy('name')
                    ->where('id', '!=', $auth_user->id)
                    ->whereHas('company', function ($query) use($auth_user) {
                          $query->where('id', '<>', $auth_user->company->id);
                    })
                    ->get();

theUnforgiven left a reply on Pivot Data On Query

User Model

public function company()
{
        return $this->belongsTo(Company::class);
}

Company Model

 public function users()
{
        return $this->hasMany(User::class, 'company_user', 'user_id', 'id');
}

Then within my controller I call

return Company::with('users')->where('owner_id', '=', user()->companies()->first()->id)->orderBy('name')->get();

Should be get all users associated with the authenticated user's company id like user()->companies()->first()->id shows

theUnforgiven left a reply on Pivot Data On Query

Yeah, I have the relationships setup

theUnforgiven left a reply on Pivot Data On Query

Anyone willing to lend a hand please?

22 Jan
2 months ago

theUnforgiven started a new conversation Pivot Data On Query

I have a basic query to get all users:

return User::orderBy('name')
                    ->where('id', '!=', auth()->user()->id)
                    ->get();

But I also have a company_user pivot table, which within the above query I need to pass this in, allowing the query to show the 4 rows in the pivot table. This is then saying there are 4 users associated with this company.

This is my pivot table. !()[https://i.imgur.com/boL19Ns.png]

So my question is based on my code above, how can I get the pivot to work thus showing 4 users, whereas currently it shows 20 users, all the users on my test database which I don't want.

14 Jan
2 months ago

theUnforgiven left a reply on JQuery Not Loading Or Vue Doesn't Load Depending On....

Also it isn't a case of converting all jQuery stuff to Vue, there's too many and not enough time to do that, although I do plan to do it in the future.

theUnforgiven started a new conversation JQuery Not Loading Or Vue Doesn't Load Depending On....

If I have this

<script src="{{ mix('js/oneui.app.js') }}"></script>

!-- Laravel JS -->
<script src="{{ mix('js/laravel.app.js') }}"></script>

at the top in the <head> section jQuery works but Vue doesn't.

And vice versa if it's at the bottom Vue works then jQuery doesn't, any reason for this and how best to fix?

theUnforgiven left a reply on Laravel Tinker Problem

Glad you got it sorted ;)

13 Jan
2 months ago

theUnforgiven left a reply on Laravel Tinker Problem

What commands are you typing and what does it show? Perhaps a screenshot or short video to show us all.

07 Jan
2 months ago

theUnforgiven left a reply on Running Supervisor On Mac With Valet?

I do have Horizon and Telescope installed, but just want a way for the queues and jobs to run without having to keep typing artisan queue:work

theUnforgiven started a new conversation Running Supervisor On Mac With Valet?

I'm wondering is there a way to auto run queues etc with Supervisor on a mac, I'm currently using Laravel Valet as it's nice and simple and effective to use, but rather than keep running 'artisan queue:work' every time I want something to run, how does one get Supervisor installed on a mac to do this?

06 Jan
2 months ago

theUnforgiven left a reply on Grouping Users Within Vue Chat

Anyone have any suggestions please?

04 Jan
2 months ago

theUnforgiven left a reply on Grouping Users Within Vue Chat

Anyone have any suggestions please

theUnforgiven started a new conversation Grouping Users Within Vue Chat

So this is the code I have to get users and associated tenants and agents (not sure if it's right either)

return User::orderBy('name')
                    ->where('id', '!=', auth()->user()->id)
                    ->with('companies', 'tenants', 'agents')
                    ->get();

Then within the Vue app this code:

<template>
    <div>
        <div class="row"> 
            <div class="col-md-3">
                <p class="float-left">Users</p><br /><br />
                <ul class="nav flex-column">
                    <li v-for="user in users"
                        class="nav-link"
                        :key="user.id"
                        @click="openChat(user.id)"
                        :class="{'font-weight-bold': chatUserID === user.id}">
                        <a href="#">{{ user.name }}</a>
                    </li>
                </ul>
            </div>
            <div class="col-md-9">
                <div class="row">
                    <div class="col">
                        <div v-show="loadingMessages">
                            <p>Loading messages... Please wait</p>
                        </div>
                        <div v-show="!chatOpen && !loadingMessages">
                            <p>Please click on user to start a conversation</p>
                        </div>
                    </div>
                </div>
                <div v-show="chatOpen && !loadingMessages">
                    <div class="row" ref="messageBox">
                        <div class="col-12 text-right shadow-sm" v-for="message in messages"
                             :class="{'p-3 mb-2 bg-secondary rounded text-white text-left': message.sender_id !== chatUserID}">
                            <small class="h6 text-right">{{ message.sender.name }}</small><br />
                            <small class="date">{{ message.created_at | formatDate }}</small>
                            <p class="font-weight-light msg rounded">
                                {{ message.message }}
                            </p>
                        </div>
                    </div>
                    <br />
                    <div class="row">
                        <div class="col col-12">
                            <div class="input-group mb-3">
                                <input type="text"
                                       class="form-control"
                                       placeholder="Start typing...."
                                       aria-label="New message"
                                       aria-describedby="button-addon2" v-model="newMessage"
                                       @keyup="typingIndicatorOn(user.name)"
                                >
                                <div class="input-group-append">
                                    <button class="btn btn-primary"
                                            type="button"
                                            id="button-addon2"
                                            @click="sendMessage">
                                        Send message
                                    </button>
                                </div>
                            </div>
                            <div :class="['dots', isTyping ? 'active' : '']">• • •</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
  export default {
    name: 'ChatApplication',
    data: () => {
      return {
        users: [],
        messages: [],
        chatOpen: false,
        chatUserID: null,
        loadingMessages: false,
        newMessage: '',
        isTyping: false
      }
    },
    created () {
      let app = this
      app.loadUsers()
    },
   
    watch: {
      messages: function () {
        let element = this.$refs.messageBox
        element.scrollTop = element.scrollHeight
      }
    },
    methods: {
        typingIndicatorOn (e, user) {
          if(_.indexOf(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'], e.code) == -1){
            if(!this.isTyping){this.isTyping = true}
            _.debounce(this.typingIndicatorOff, 1600)()
          }
        },
        typingIndicatorOff () {this.isTyping = false},

      openChat (userID) {
        let app = this
        if (app.chatUserID !== userID) {
          app.chatOpen = true
          app.chatUserID = userID

          // Start pusher listener
          //Pusher.logToConsole = true

          var pusher = new Pusher('xxxxx', {
            cluster: 'eu',
            forceTLS: true
          })

          var channel = pusher.subscribe('newMessage-' + app.chatUserID + '-' + app.$root.userID) // newMessage-[chatting-with-who]-[my-id]

          channel.bind('App\Events\MessageSent', function (data) {
            if (app.chatUserID) {
              app.messages.push(data.message)
            }
          })
          // End pusher listener
          app.loadMessages()
        }
      },
      loadUsers () {
        let app = this
        axios.get('api/users')
          .then((resp) => {
            app.users = resp.data
          })
      },
      loadMessages () {
        let app = this
        app.loadingMessages = true
        app.messages = []
        axios.post('api/messages', {
          sender_id: app.chatUserID
        }).then((resp) => {
          app.messages = resp.data
          app.loadingMessages = false
        })
      },
      sendMessage () {
        let app = this
        if (app.newMessage !== '') {
          axios.post('api/messages/send', {
            sender_id: app.$root.userID,
            receiver_id: app.chatUserID,
            message: app.newMessage
          }).then((resp) => {
            app.messages.push(resp.data)
            app.newMessage = ''
          })
        }
      }
    }
  }
</script>

So basically I want to group users in the list by who are tenants and who are agents etc, then have a label above each group, how can this be achieved?

theUnforgiven left a reply on Time/Date When Queuing Notifications

So I figured I had to convert the date to unix by doing:

$when = Carbon::createFromFormat('Y-m-d H:i' , $request->alert_date ,'Europe/London');
$when->timestamp; 

Which seems to have solved the problem.

theUnforgiven left a reply on Time/Date When Queuing Notifications

So in essence I want the job processed at the time the user specifies i.e '"2019-01-04 10:40"'

theUnforgiven started a new conversation Time/Date When Queuing Notifications

Hi all,

Hope everyone had a great Christmas and New Year is off to a good start.

I'm looking for some help/advice. I have a basic form for adding tasks of which the user can specify a date & time the want to be notified at. So the string that comes back is as follows:

"2019-01-04 10:40"

When I then use with the following statement:

$when = $request->alert_date;
$user = User::find($id);
$user->notify((new TaskAlert($task))->delay($when))->onQueue('high');

But it appears when it adds to the database "jobs" table the unix time is wrong, thus sending the notification later than what it should, in this case "2019-01-04 10:40"

Any help/advice greatly appreciated.

19 Dec
3 months ago

theUnforgiven started a new conversation TailwindCSS Installed But JS Stopped Working

Hi all,

I have installed Tailwind and the relevant Tailwind.js file which is all good but now all the jquery and other JS stuff as stopped working.

I wondered if anyone else encountered this problem and how did you overcome it?

14 Dec
3 months 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);