realrandyallen

realrandyallen

Member Since 3 Years Ago

Sarasota, FL

Experience Points 168,620
Experience Level 34

1,380 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 618
Lessons
Completed
Best Reply Awards 173
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.

04 Mar
3 months ago

realrandyallen left a reply on Vue: Error In Render: "TypeError: Event Is Undefined"

Add $event into your click call

@click="selectProduct(product, $event)" 
01 Mar
3 months ago

realrandyallen left a reply on Invoice Number In Controller

You can use sprintf for this:

$invnum = sprintf('%05d', $invnum + 1);
28 Feb
3 months ago

realrandyallen left a reply on Laravel API GroupBy Format

Consider this structure:

$students = Student::whereIn('subject_id', $subjects)->orderBy('grade')->get()->groupBy('subject_id');

return response(['success' => true, 'data' => $students]);

realrandyallen left a reply on Call To A Member Function Connection() On Null

@MDELSHAD - Does your helper file look like this?

use App\Setting;

if (! function_exists('getSetting')) {

    /**
     * @param $setting
     *
     * @return string
     */
    function getSetting($setting)
    {
        return Setting::where('name',$setting)->first()->val;
    }


}

realrandyallen left a reply on Getting An Invoice Number To Be Generated

@NIKKI - That's only because of this:

        if($orders->isEmpty())
        {
            $invoice = 'arm0001';
            return $invoice;
        }

Once the table has a record it will probably fail again...

I didn't notice this at first, but why loop all orders? Something like this should work:

function invoiceNumber()
    {
        $latest = App\Order::latest()->first();

        if (! $latest) {
            return 'arm0001';
        }

    return 'arm' . sprintf('%04d', $latest->id+1); // sprintf will add leading zeros to the invoice number
    }

realrandyallen left a reply on Call To A Member Function Connection() On Null

@MDELSHAD - Post the code that calls this function

realrandyallen left a reply on Call To A Member Function Connection() On Null

Could be a naming conflict since the function is named the same as your Model - depends on how you're importing them and calling the Settingfunction.

As as test you could rename it getSetting or something similar

realrandyallen left a reply on Getting An Invoice Number To Be Generated

I think your issue is here:

if($latest->order == true)

$latest already appears to be an order, perhaps this should be:

foreach($orders as $order)
{
    $latest = App\Order::latest()->first();

    if ($latest) {
        return 'arm' . $latest->id+1;
    }
}
26 Feb
3 months ago

realrandyallen left a reply on Fetch Strtotime Data As Time Format With Am And Pm

@DEEKSHITH - One option is to use an accessor so you don't have to worry about using php or js to format the time in your view:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    ...
    
    protected $appends = [
        'start_time_formatted'
    ];
    ...
    
    public function getStartTimeFormattedAttribute()
    {
        return date('H:i A', $this->start_time)
    }

    ...
}

https://laravel.com/docs/master/eloquent-mutators#defining-an-accessor

21 Feb
4 months ago

realrandyallen left a reply on Laravel Router Macro

@SEHMBIMANVIR - You're welcome! Please mark as solved

realrandyallen left a reply on How Can I Make Different HTML And Component Files In Vue.js?

Vue has components and those components can have child components. You can look at them as 'partials' (in a way) to separate your code into different files that make sense.

https://vuejs.org/v2/guide/components.html

20 Feb
4 months ago

realrandyallen left a reply on Laravel Router Macro

Do you have parent::boot(); in your RouteServiceProvider still? If so you may need to put it after the macro code

15 Feb
4 months ago

realrandyallen left a reply on How To Create An Edit Button In Vue.js And Laravel That Goes To Edit Url?

@MUNAZZIL - I think you need to restructure things, that link should go to a get route that display a form with inputs so you can edit the Book's values

<a v-bind:href="'books/edit/'+book.id">Edit</a>

Route::put('books/edit/{book}', '[email protected]'); // or your ApiController

When you submit that form you will then hit this route to save the inputted data:

Route::put('books/{book}', '[email protected]'); // or your ApiController

realrandyallen left a reply on How To Create An Edit Button In Vue.js And Laravel That Goes To Edit Url?

@MUNAZZIL - You'll need the id:

<a v-bind:href="'edit/'+book.id"> Edit </a>

realrandyallen left a reply on How To Create An Edit Button In Vue.js And Laravel That Goes To Edit Url?

You're missing a single quote:

 <a v-bind:href="'edit/'+id+'"> Edit </a>
13 Feb
4 months ago

realrandyallen left a reply on How To Sort A GroupBy?

Try adding the year into your order:

$commemoratives = Commemorative::orderByRaw('year desc, month desc')->paginate(15)->groupBy('year');

realrandyallen left a reply on Problem Usin Fineuploader In Laravel..

@JPMG - I think you'll find your answer in this stackoverflow post, has to do with your apache config:

https://stackoverflow.com/a/11289275

realrandyallen left a reply on Not Compiling Changes In Vue.js Files.

Any errors in the terminal when you run npm run dev? Also what's in your webpack.mix.js file?

realrandyallen left a reply on Get Position In Rating By Scope

@DRONAX - reviews_count isn't in your database table, so MySQL doesn't know what it is - you'd need to create it as a field on that table and keep it updated with the correct numbers before you updateRanks

12 Feb
4 months ago

realrandyallen left a reply on Problem Usin Fineuploader In Laravel..

Have you tried settings the permissions on the files folder inside your public directory? Depending on which user owns the file it will need to be either 755 or 775

realrandyallen left a reply on How To Store Result Of Expensive Request?

Use Laravel's Cache system:

$value = Cache::rememberForever('users', function () {
    return DB::table('users')->get();
});

If the users key exists in the cache Laravel will automatically use those results and not re-run the query. If the key does not exist yet Laravel will run the query and store the results in the cache for later use.

https://laravel.com/docs/master/cache#storing-items-in-the-cache

realrandyallen left a reply on Eager Loading

Yup

Nested Eager Loading To eager load nested relationships, you may use "dot" syntax. For example, let's eager load all of the book's authors and all of the author's personal contacts in one Eloquent statement:

$books = App\Book::with('author.contacts')->get();

https://laravel.com/docs/master/eloquent-relationships#eager-loading

realrandyallen left a reply on Vue.js Handling If Status == 1 | Status == 2 | Status = 3

You can use a switch statement in a computed property to solve both issues, but you may want to use an accessor on your model - that way you have access to these values everywhere

// Model
class Task extends Model
{
    ...

    protected $appends = [
        'status_readable',
        'status_class'
    ];

    ...

    public function getStatusReadableAttribute
    {
        switch($this->status) {
            case 1:
                return "Not Started";
            case 2:
                return "In Progress";
            case 3:
                return "Stuck On Task";
            default:
                return null;
        }
    }

    public function getStatusClassAttribute
    {
        switch($this->status) {
            case 1:
                return "not-started";
            case 2:
                return "in-progress";
            case 3:
                return "stuck-on-class";
            default:
                return null;
        }
    }

    ...
}

// Component
<template>
    <div>
        <div :class="task.status_class">{{ task.status_readable }}</div>
    </div>
</template>

https://laravel.com/docs/master/eloquent-mutators#accessors-and-mutators

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

@THEUNFORGIVEN - What I said in my latest post would solve the issue - it just puts the form into the component - that way the component has access to all of the data in the form and then you could submit it all via an axios post request

11 Feb
4 months ago

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

@THEUNFORGIVEN - Yeah that pretty much changes everything :)

Easiest way from here is to take your regular form tag and everything with it and add it to this component as well.

// edit-company-profile.blade.php
<div>
    <edit-company-profile :company="{{ $company }}"></edit-company-profile>
</div>

Alternatively you could and make it a separate vue component and then take what I've made and put it in that new component as a Fees child component. Soemthing like:

//EditCompanyProfile.vue

<form method="POST" action="/company/profile">
    // profile fields etc.

    <fees :data="company.fees"></fees>
</form>

...

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

Assuming you want to submit them via axios to a route that saves them to the DB:

<template>
    <div>
        <form @submit.prevent="saveInputs">
            <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" 
                                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" 
                                    v-model="input.fee" 
                                >
                                <button v-on:click.prevent="removeInput(inputs[index])" 
                                        class="btn btn-sm btn-danger">
                                        Delete
                                </button>
                            </div>   
                        </div>
                    </div>
                </div>
            </div>
            <button v-if="inputs.length" type="submit" class="btn btn-sm btn-outline-secondary mt-1 mb-3">Save</button>
        </form>

        <h2>Add New</h2>
        <form @submit.prevent="addInput">
            <div class="row">
                <div class="col">
                    <div class="form-group">
                        <input type="text" 
                            class="form-control"
                            v-model="newInput.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" 
                                v-model="newInput.fee"
                            >
                        </div>   
                    </div>
                </div>
            </div>
        
            <button type="submit" class="btn btn-sm btn-outline-secondary mt-1 mb-3">Add</button>
        </form>
    </div>
</template>

<script>

    export default {

        data() {
            return {
                counter: 0,
                inputs: [],
                newInput: {},
            }
        },

        methods: {
            addInput(e) {
                this.inputs.push(this.newInput);
                this.newInput = {};
            },
            
            removeInput : function (input) {
                this.inputs.splice(input, 1);
            },

            saveInputs() {
                axios.post('/some-route-endpoint', this.parsed).then(response => {
                    console.log(response);
                }).catch(error => {
                    console.error(error);
                });
            }
        },

        computed: {
            parsed() {
                return _.mapValues(
                    _.mapKeys(this.inputs, 'item'),
                'fee');
            }
        },
    }

</script>

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

Would this work for you? It separates the concerns of displaying existing values and adding new ones. I find it easier to maintain the datasets that way. Then you can use the parsed computed value to get the format you're looking for in your original post.

<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" 
                            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" 
                                v-model="input.fee" 
                            >
                            <button v-on:click.prevent="removeInput(inputs[index])" 
                                    class="btn btn-sm btn-danger">
                                    Delete
                            </button>
                        </div>   
                    </div>
                </div>
            </div>
        </div>

        <h2>Add New</h2>
        <form @submit="addInput">
            <div class="row">
                <div class="col">
                    <div class="form-group">
                        <input type="text" 
                            class="form-control"
                            v-model="newInput.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" 
                                v-model="newInput.fee"
                            >
                        </div>   
                    </div>
                </div>
            </div>
        
            <button type="submit" class="btn btn-sm btn-outline-secondary mt-1 mb-3">Save</button>
        </form>
    </div>
</template>

<script>

    export default {

        data() {
            return {
                counter: 0,
                inputs: [],
                newInput: {},
            }
        },

        methods: {
            addInput(e) {
                e.preventDefault();

                this.inputs.push(this.newInput);
                this.newInput = {};
            },
            removeInput : function (input) {
                this.inputs.splice(input, 1);
            }
        },

        computed: {
            parsed() {
                return _.mapValues(
                    _.mapKeys(this.inputs, 'item'),
                'fee');
            }
        },
    }

</script>

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

Can you post the entire component?

realrandyallen left a reply on Form Submit Not Working

@SHOKEN - Not sure if the casing is messing it up by try:

// change
Route::resource('Message','MessageController');

// to 
Route::resource('message','MessageController');

I'd also look at/post the raw html that's being generated by the browser so we can make sure the form is being created as expected. View Source in the Browser and let's see what that plugin generated.

realrandyallen left a reply on Vuejs Bootstrap DateTimePicker

@JAP115 - Did you make sure to run npm run dev after making your changes?

09 Feb
4 months ago

realrandyallen left a reply on Vue Js V-for Loop On Arrays

I'd use a computed property to flatten your data, it'll make your loop clean

<template>
    <div>
        <ul>
            <li v-for="row in flattened">{{ row.var }}</li>
        </ul>
    </div>
</template>

<script>

export default {
    data () {
        return {
            dataReceived: {
                data: [
                    [{
                        var: 'test'
                    }],
                    [{
                        var: 'test2'
                    }],
                ]
            }
        }
    },
    computed: {
        flattened() {
            return _.flatten(this.dataReceived.data);
        }
    },
}
</script>

08 Feb
4 months ago

realrandyallen left a reply on How To Get All Children Recursively?

Scroll down to 'Nested Eager Loading'

https://laravel.com/docs/master/eloquent-relationships#eager-loading

Say your children are groups and each group has contacts

// User Model
public function groups()
{
    return $this->hasMany('App\Group', 'parent_id', 'id');
}

//Group Model
public function contacts()
{
    return $this->hasMany('App\Contact', 'parent_id', 'id');
}

$users = User::with('groups.contacts')->get();

realrandyallen left a reply on (2/2) QueryException SQLSTATE[42S02]: Base Table Or View Not Found: 1146 Table 'programmer.channels' Doesn't Exist (SQL: Select * From `channels`)

Looks like you get this error when you try to run php artisan migrate ? If so, it looks like one of your migrations is trying to use the channels table before it actually exists

Or some other code is trying to use a channels table that doesn't actually exist.

realrandyallen left a reply on Laravel Models

@SHOAIB768 - No problem, best of luck!

realrandyallen left a reply on Vuejs Bootstrap DateTimePicker

You've imported the solid icons but some of the icons you have namespaced as the regular style, try changing:

close: 'far fa-times-circle'

to

close: 'fas fa-times-circle'

realrandyallen left a reply on Laravel Models

Laravel does use the Model name to assume a table name (plural of the model)...but you can of course override that by specifying a $table variable in your Model

Scroll down to 'Table Names':

https://laravel.com/docs/master/eloquent#introduction

realrandyallen left a reply on Help Needed Adding Key-value Pair To Sub-array In Collection.

This still kinda grosses me out but I think it's a step in the right direction, the fact that you only need the first one transformed makes it a bit messy

$found = false;

$items = $collection->transform(function ($item) use (&$found) {
    if (! $found && $item['type'] == "Clove") {
        $item['category'] = 'spice';
        $found = true;
    };

        return $item;
});
07 Feb
4 months ago

realrandyallen left a reply on Adding Factory To Test POST

Try:

$response = $this->actingAs($admin)->post('/admin/airline', factory(Airline::class)->raw());

realrandyallen left a reply on QueryException In Connection.php Line 770:

You'll need to feed a stream_id to your create query, or use eloquent relationships to have it set automatically, i.e.

$stream->registrations->create($data);

If stream_id is optional you need to update your migration to make that field nullable:

$table->unsignedInteger('stream_id')->nullable();

realrandyallen left a reply on Component Not Found

You may need to run php artisan nova:publish

06 Feb
4 months ago

realrandyallen left a reply on Need Help With JQuery

Try structuring it like this:

$(document).ready(function () {
$(".calc").bind("keyup change", function(e) {
    convert()
});

function convert () {
    $.ajax({
        'url': 'https://apis.is/currency/arion',
        'type': 'GET',
        'dataType': 'json',
        'success': function(response) {
            console.log(response);

            var text_ISK    =   response.results[0].shortName;
            var text_EUR    =   response.results[3].shortName;
            var text_USD    =   response.results[1].shortName;
            var text_GBP    =   response.results[2].shortName;

            var input_ISK    =   response.results[0].value;
            var input_EUR    =  response.results[3].value;
            var input_USD    =  response.results[1].value;
            var input_GBP    =  response.results[2].value;

            $('#text_ISK').append(text_ISK);
            $('#text_EUR').append(text_EUR);
            $('#text_USD').append(text_USD);
            $('#text_GBP').append(text_GBP);

            var first_val_eur = input_ISK / input_EUR;
            var first_val_usd = input_ISK / input_USD;
            var first_val_gbp = input_ISK / input_GBP;

            $('#ISK').val(input_ISK);
            $('#EUR').val(first_val_eur.toFixed(2));
            $('#USD').val(first_val_usd.toFixed(2));
            $('#GBP').val(first_val_gbp.toFixed(2));

            
                var val_eur = input_ISK / input_EUR;
                var val_usd = input_ISK / input_USD;
                var val_gbp = input_ISK / input_GBP;

                if (!isNaN(val_eur) && val_eur !== Infinity) {
                    $("#EUR").val(val_eur.toFixed(2));
                }

                if (!isNaN(val_usd) && val_usd !== Infinity) {
                    $("#USD").val(val_usd.toFixed(2));
                }

                if (!isNaN(val_gbp) && val_gbp !== Infinity) {
                    $("#GBP").val(val_gbp.toFixed(2));
                }
        }
    });
}

});

realrandyallen left a reply on Vue-full-calendar Not Working Refetch-events

@HUZOORBUX - Based on the documentation I don't think it's going to work how you expect unless you specify an event-scource

<full-calendar ref="calendar" :event-sources="eventSources"></full-calendar>

refetch-events() - Makes another JSON call to event sources

Check out the 'Using a JSON Feed' section

https://www.npmjs.com/package/vue-full-calendar

realrandyallen left a reply on Vue-full-calendar Not Working Refetch-events

@HUZOORBUX - Change @onchange to @change

@change="refreshEvents()"

You also have the ref calendar assigned to two separate components...that may or may not cause an issue as well

realrandyallen left a reply on Vue-full-calendar Not Working Refetch-events

Can you post the full component?

realrandyallen left a reply on Laravel Charts - Not Loading

@NICKDAVIES07 - You might wanna go through and comment out each line one at a time and see if you charts still load, that way you can narrow down exactly where the issue is