realrandyallen

realrandyallen

Member Since 3 Years Ago

Sarasota, FL

Experience Points
178,100
Total
Experience

1,900 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
666
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.

Level 36
178,100 XP
Sep
03
1 month ago
Activity icon

Commented on Inline SVGs Using Render Functions

Glad to help!

Aug
26
1 month ago
Activity icon

Replied to Laravel CRUD Delete Function Using Ajax

Did you try what I said?

Activity icon

Replied to Laravel CRUD Delete Function Using Ajax

Looks like you're targeting the delete button incorrectly, you're trying to target it by using .delete but the delete button doesn't have that class, it has the deleteButton class...try this:

 $(document).on('click', '.deleteButton', function() {
   ....

Aug
20
1 month ago
Activity icon

Replied to How To Clear Filter In Vue Table 2

I don't believe so

Aug
19
1 month ago
Activity icon

Replied to 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

Activity icon

Replied to 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);
    }
Activity icon

Replied to 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

Activity icon

Replied to 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>
Activity icon

Replied to 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/

Activity icon

Replied to 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

Activity icon

Replied to 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');

Activity icon

Replied to 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);
    }
Aug
17
2 months ago
Activity icon

Replied to 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

Activity icon

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

Aug
16
2 months ago
Activity icon

Replied to Vue Table 2 : How To Get The Nested Array

Here's one way:

let userNames = results[0]['users'].map(u => u.name)
Aug
09
2 months ago
Activity icon

Replied to 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

Activity icon

Replied to 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();
Aug
08
2 months ago
Activity icon

Replied to 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

Activity icon

Replied to 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

Aug
04
2 months ago
Activity icon

Replied to Laravel Keyup Function Not Working

No problem, glad it's working :)

Activity icon

Replied to “TypeError: Cannot Read Property 'open' Of Undefined”

In the LaraToaster.vue component...

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

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

Replied to 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(...)
Activity icon

Replied to 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');
            }
        }

Jul
25
2 months ago
Activity icon

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' : ''"
Activity icon

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!

Activity icon

Replied to 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)

Activity icon

Replied to 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;

...
Mar
04
7 months ago
Activity icon

Replied to Vue: Error In Render: "TypeError: Event Is Undefined"

Add $event into your click call

@click="selectProduct(product, $event)" 
Mar
01
7 months ago
Activity icon

Replied to Invoice Number In Controller

You can use sprintf for this:

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

Replied to 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]);
Activity icon

Replied to 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;
    }


}
Activity icon

Replied to 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

Activity icon

Replied to Call To A Member Function Connection() On Null

@MDELSHAD - Post the code that calls this function

Activity icon

Replied to 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

Activity icon

Replied to 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;
    }
}
Feb
27
7 months ago
Feb
26
7 months ago
Activity icon

Replied to 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

Feb
21
7 months ago
Activity icon

Replied to Laravel Router Macro

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

Activity icon

Replied to 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

Feb
20
7 months ago
Activity icon

Replied to 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

Feb
15
8 months ago
Activity icon

Replied to 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
Activity icon

Replied to 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>
Activity icon

Replied to 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>
Feb
13
8 months ago
Activity icon

Replied to How To Sort A GroupBy?

Try adding the year into your order:

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

Replied to 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

Activity icon

Replied to 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?

Activity icon

Replied to 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