realrandyallen

realrandyallen

Member Since 3 Years Ago

Sarasota, FL

Experience Points 176,120
Experience Level 36

3,880 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 649
Lessons
Completed
Best Reply Awards 181
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

20 Aug
20 hours ago
19 Aug
1 day ago

realrandyallen left a reply on Does Supervisor Needs A Restart If The Config Changes?

Ah I see, yes I would think you'd be fine after a

php artisan config:cache

That also clears the cache first so you should be ok

realrandyallen left a reply on How To Hide Login Form After Reaching The Total Of Failed Login Attempts?

I think the issue is when you're calling $this->hasTooManyLoginAttempts($request) you're passing through the request but it does not have a username field. To detect if there has been to many attempts Laravel generates a key using the username field:

    protected function throttleKey(Request $request)
    {
        return Str::lower($request->input($this->username())).'|'.$request->ip();
    }

Because there is no username from showLoginForm your keys aren't matching so that will never result in true. I think you'd be better off overriding the login function instead and change it to return your auth.block view rather than sending a lockout response:

    public function login(Request $request)
    {
        $this->validateLogin($request);

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if (method_exists($this, 'hasTooManyLoginAttempts') &&
            $this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            // old
            //return $this->sendLockoutResponse($request);
        
           // new 
           return view('auth.block', array(
                'seconds' => $this->limiter()->availableIn($this->throttleKey($request))
           ));
        }

        if ($this->attemptLogin($request)) {
            return $this->sendLoginResponse($request);
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

        return $this->sendFailedLoginResponse($request);
    }

realrandyallen left a reply on Does Supervisor Needs A Restart If The Config Changes?

I'm pretty sure you have to do a reread of the config file:

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start laravel-worker:*

https://laravel.com/docs/master/queues#supervisor-configuration

realrandyallen left a reply on Vue.js And Davejamesmiller/laravel-breadcrumbs

Untested but it should look something like:

Some view

...

<div>
   <bread-crumbs :crumb-data="{{ $breadcrumbs }}"></bread-crumbs>
</div>

...

BreadCrumbs.vue

<template>
    <div>
        <ol v-if="crumbs.length" class="breadcrumb">
            <li
                v-for="(crumb, index) in crumbs"
                class="breadcrumb-item"
                :class="{ active: index != crumbs.length - 1 }">
                    <a v-if="index != crumbs.length - 1" :href="crumb.url">
                        {{ crumb.title }}
                    </a>
                    <div v-else>{{ crumb.title }}</div>
            </li>
        </ol>
    </div>
</template>

<script>
  export default {
    props: {
        crumbData: {
            type: [Array, Object],
            required: true
        }
    },

    data() {
        return {
            crumbs: this.crumbData;
        }
    }
}
</script>

realrandyallen left a reply on How To Clear Filter In Vue Table 2

Give the button a click event that calls the new clearFilters method, give the table a ref of "table"

https://jsfiddle.net/ysdot37j/

realrandyallen left a reply on Want To Convert Sql Query To Laravel

I'd use a selectRaw statement, something like this:

$data = Doctor::selectRaw('(
          6371* acos (
            cos ( radians(12.9166) )
            * cos( radians( lat ) )
            * cos( radians( long ) - radians(77.6101) )
            + sin ( radians(12.9166) )
            * sin( radians( lat ) )
          )
        ) AS distance')
    ->having('distance', '<', '5')
    ->orderBy('distance')
    ->limit(20)
    ->get();

https://laravel.com/docs/master/queries#raw-expressions

realrandyallen left a reply on Group By Doesnot Work

Your return from the map is overwriting the value of $item, so you'd have to add to the $item then return it, something like:

SancofaUser::where('created_at', '>=', $days_after_now)
   ->groupBy('department')
   ->get()
   ->keyBy('department')
   ->map(function($item, $key) {
      $item['count'] = count($item);
   
      return $item;
   });

However, you'd be better of doing this with query builder rather than looping over the results afterwards, something like:

$data = DB::table("yourtablename")
   ->select("department", DB::raw("COUNT(*) as count"))
   ->groupBy("department")
   ->get()
   ->keyBy('department');

realrandyallen left a reply on Build Laravel App With TDD Series 2 Testing Issue

Make sure all your test functions start with the word test or you use the @test annotation in your docblock

    /** @test **/
    public function testBasicTest()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
17 Aug
3 days ago

realrandyallen left a reply on Vue Table 2 : When I Change The Page The Checkbox Is Checked Automatically

Adding a key to the checkbox would probably fix that

<input type="checkbox" slot="uri" slot-scope="props" :key="props.row.id" >

Not sure if the state of the checkbox would be preserved if you went back to the original page though

realrandyallen commented on Token-Based API Authentication

NULL values don't count :)

A UNIQUE index permits multiple NULL values for columns that can contain NULL.

https://dev.mysql.com/doc/refman/8.0/en/create-index.html#create-index-unique

16 Aug
4 days ago

realrandyallen left a reply on Vue Table 2 : How To Get The Nested Array

Here's one way:

let userNames = results[0]['users'].map(u => u.name)
09 Aug
1 week ago

realrandyallen left a reply on How To Find Parent_id Count?

I apologize I just went back and realized I totally read your issue wrong, I need to go make more coffee.

The solution from @clevonnoel looks good

realrandyallen left a reply on How To Find Parent_id Count?

In your Order model I would imagine you have a relationship to products:

public function products()
{
        return $this->hasMany(Product::class);
}

If so, then this should work:

// do this
$orderCount = Order::whereHas('user')->withCount('products')->get();

// not this
$orderCount = Order::whereHas('user')->withCount('parent_id')->get();
08 Aug
1 week ago

realrandyallen left a reply on Laravel Shows “humans_21909=1” Error Whenever Post Data Using Postman.

Check out this comment on stackoverflow, is your route named register or maybe some other name that may cause an issue?

Thanks to everyone. But it is working now, I changed my route url from register to reg and function name from register to reg1 and it started working. I don't know how but may be the issue of unique keywords like register in laravel was causing the problem (still don't know)

https://stackoverflow.com/questions/54997928/post-request-return-script-from-live-server-but-works-on-local-server#comment96800393_54997928

realrandyallen left a reply on How To Find Parent_id Count?

If you have the proper products relationship setup in your Order model you can just use withCount

public function index()
{
    return Order::with('user')->withCount('products')->get();
}

https://laravel.com/docs/master/eloquent-relationships#counting-related-models

04 Aug
2 weeks ago

realrandyallen left a reply on Laravel Keyup Function Not Working

No problem, glad it's working :)

realrandyallen left a reply on “TypeError: Cannot Read Property 'open' Of Undefined”

In the LaraToaster.vue component...

// change this...
this.$toast.open

// ... to this
this.$buefy.toast.open

realrandyallen left a reply on Laravel Keyup Function Not Working

$('#n_serie') is targeting an element with an id of n_serie, your input doesn't have an id, the name attribute is n_serie

// give the input an id attribute...
<input type="text" id="n_serie" name="n_serie" required="required" class="form-control" />

// ...or find the input by name instead
$("input[name='n_serie']").keyup(...)

realrandyallen left a reply on Error During Evaluation

Try adding this in front of selectedValue

        computed: {
            dates: function() {
                this.start = moment(this.selectedValue.start);
                this.end = moment(this.selectedValue.end);

                return this.start.diff(this.end, 'days');
            }
        }

25 Jul
3 weeks ago

realrandyallen commented on Tabs

Great lesson!

Small tip with tailwind, you can do -mb-px for a margin-bottom of -1px, that would have saved you from having to do

:style="tab.isActive ? 'margin-bottom: -1px' : ''"

realrandyallen commented on Inline SVGs Using Render Functions

As mentioned before this is a followup to: https://laracasts.com/series/whatcha-working-on/episodes/38

In that lesson Jeffrey covers the update needed to your webpack.mix.js file to get this to work, here it is below:

    .override(config => {
        config.module.rules.find(rule =>
            rule.test.test('.svg')
        ).exclude = /\.svg$/;

        config.module.rules.push({
            test: /\.svg$/,
            use: [{ loader: 'html-loader' }]
        })
    });

This will tell webpack to use html-loader rather than file-loader to process .svg files

If you're running npm run watch restart the watcher to make sure your changes apply

Side Note

If you're using tailwind like me (or just want to add multiple classes separated by a space) I found myself wanting to do this:

<inline-svg name="home" classes="text-grey-dark fill-current h-3 w-3 mr-2"></inline-svg>

This will fail because of the spaces inbetween class names, in order to get this to work I changed the classes function in InlineSvg.js to this:

    classes(classes) {
        if (classes) {
            classes.split(' ').forEach(className => {
                this.svg.classList.add(className);
            });
        }

        return this;
    }

Happy coding!

realrandyallen left a reply on Create Function Adds 0 As Additional Parameter

If you do have an auto-incrementing ID field on the table then adding $incrementing = false to your model isn't the proper solution (I thought maybe you didn't have an auto-incrementing field on the table)

realrandyallen left a reply on Create Function Adds 0 As Additional Parameter

What's the primary key on the table? I'm wondering if you just need to add this at the top of your CountingList model

...

class CountingList extends Model
{
    public $incrementing = false;

...
04 Mar
5 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
5 months ago

realrandyallen left a reply on Invoice Number In Controller

You can use sprintf for this:

$invnum = sprintf('%05d', $invnum + 1);
28 Feb
5 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
}

This assumes your order table has an id field...if it doesn't that's probably why you got the non-numeric error

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
5 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
5 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
6 months ago

realrandyallen left a reply on Laravel Router Macro

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

15 Feb
6 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::get('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 have an extra single quote:

 <a v-bind:href="'edit/'+id"> Edit </a>
13 Feb
6 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
6 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 directory 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