realrandyallen

realrandyallen

Member Since 2 Years Ago

Sarasota, FL

Experience Points 165,740
Experience Level 34

4,260 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 615
Lessons
Completed
Best Reply Awards 169
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.

15 Feb
5 days 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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
1 week 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
2 weeks 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

05 Feb
2 weeks ago

realrandyallen left a reply on Data Is Inserting In Db But Displaying Error

@PROGRAMMER111 - You're not using that code? It's right there in the controller...but, it could also be related to your session driver I suppose:

Look at the last post here:

https://laravel.io/forum/12-02-2014-get-maximum-execution-time-of-30-seconds-exceeded-from-time-to-time

I'd still test the email thing if you haven't

realrandyallen left a reply on Data Is Inserting In Db But Displaying Error

@PROGRAMMER111 - Any change if you comment out all the code that sends emails?

realrandyallen left a reply on Data Is Inserting In Db But Displaying Error

I've only run into this with accidental infinite loops, which can happen with eager loading if you aren't careful. Since the data is going into the DB successfully what happens after that?

You may need to comment out code step by step to see when the problem happens to narrow down which piece of code is causing the issue.

realrandyallen left a reply on Data Is Inserting In Db But Displaying Error

Do you get the error when you attempt to login with the new account or elsewhere?

realrandyallen left a reply on Explode Query Builder Results

@MANOJOW - Not sure if there's going to be a better way to do it unless you use Eloquent to setup proper relationships between the two tables so you can do something like:

$local->units

Then you wouldn't have to worry about pulling a string of unit_ids then exploding them into an array. Either way though, just for clarification, you aren't working with the Query builder here anymore since you get(), at that point you're working with a collection so technically this would be the same thing:

->groupBy("tbl_locales.id")->get()->each(function($local){
    $local->unit_ids = explode(",", $local->unit_ids);
});

realrandyallen left a reply on DB Builder Return 0 Results

Make sure all your variables are what you expect them to be, also try hard coding the values as a test to see if you get results or not.

Outside of that I would use the query log, Telescope or Debugbar to show me the exact SQL that's being ran so you can confirm it's the same as your raw sql query that you're getting results from

realrandyallen left a reply on Laravel 5.7 Cannot Update Database Using ->update($request->all());

@AAC2018 - Make sure approval_status is in the fillable array on your Loan model or that you have guarded set to an empty array.

Also confirm make sure $loanID and $approvalStatus are what you expect them to be

04 Feb
2 weeks ago

realrandyallen left a reply on How Can I Make This Api To Display In The Browser

Depending on how your data is coming back from your api you just need to do something like:

axios.get('/api/property').then((response) => {
    console.log(response);
    this.properties.push(response.data);
}).catch(function (error) {
    console.log(error);
});

realrandyallen left a reply on Access Auth::user() Anywhere In App Once Authenticated/optional Authentication

@BONEILL81 - Are you doing this check in the constructor of your controller?

realrandyallen left a reply on Best Practice To Avoid "property Of Non-object"?

You could use the optional helper if you wanted to avoid a conditional - although depending on your actual need a conditional may make more sense:

https://laravel.com/docs/master/helpers#method-optional

realrandyallen left a reply on Subscription

From the FAQ:

For various reasons, Paypal is not a supported option at Laracasts currently. However, if it turns out that Paypal is the only way for you to sign up, I will manually accept payments with this method at 1-year intervals.

https://laracasts.com/paypal

realrandyallen left a reply on Laravel Charts - Not Loading

Might be something happening with turbolinks...any difference if you remove that listener?

realrandyallen left a reply on Laravel Charts - Not Loading

Any errors in the console when it doesn't load properly?

31 Jan
2 weeks ago

realrandyallen left a reply on Week Number

@SWAPNA - You'll get the same exact result because Jan 7th is still the first week and the start and end of the week is the same as Jan 1st

However @Insperio is right that you may need to use weekOfYear depending on your needs

realrandyallen left a reply on Week Number

Try this out:

$date = Carbon::parse("01 Jan 2018");

$weekNumber = $date->weekNumberInMonth;
$start = $date->startOfWeek()->toDateString();
$end = $date->endOfWeek()->toDateString();

dump($weekNumber);
dump($start);
dump($end);