Chaps

Chaps

Member Since 3 Years Ago

Experience Points 9,560
Experience Level 2

440 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 52
Lessons
Completed
Best Reply Awards 3
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.

06 Apr
3 months ago

Chaps started a new conversation Slowing Down Website App

Hello guys! hope someone can help me, problem is my realtime betting website is slowing down when more than 100 concurrent users doing a requests, like they are waiting each other to be process, what seem to be my problem? is queuing is my solution? thank you!

10 Dec
7 months ago

Chaps started a new conversation Vuejs Inline Javascript Using Vue-script2

Hello, script2 is already working but I want to implement script2ify, any guide on how to implement script2ify on a laravel vue project? where do I put this function? thanks!

var through = require('through2')
// This will replace <script> with <script2> in .html, .vue and .ejs files
// EXCEPT:
// - within <!-- comments -->
// - top-level <script> tags within .vue files
// Additional exclusion per: http://www.rexegg.com/regex-best-trick.html
// Excluding <pre> tags did not seem to work, however.
function script2ify (file) {
  return !/\.(vue|html|ejs)$/.test(file) // edit to support other file types
  ? through()
  : through(function (buf, encoding, cb) {
    // avoid replacing top-level <script> tags in .vue files
    var regex = /\.vue$/.test(file)
    ? /<!--.*?-->|^<script>|^<\/script>|(?:<(\/)?script([ >]))/gm
    : /<!--.*?-->|(?:<(\/)?script([ >]))/gm
    var replacement = (m, p1, p2) => p2 ? `<${p1 || ''}script2${p2}` : m
    cb(null, buf.toString('utf8').replace(regex, replacement))
  })
}

https://github.com/taoeffect/vue-script2#writing-script-instead-of-script2-using-script2ify

26 Jan
1 year ago

Chaps started a new conversation Email Piping To A Laravel App, Get The Senders Server IP And Server Hostname, Is That Possible?

I have an email address that all email received is piped to a laravel app which then stores the headers message subject etc in a database. This works fine, but what I need to do is also get the senders server IP and server hostname, is that possible?

I am using Mailparse Extension Wrapper to parse mail and Exim.

09 Dec
1 year ago

Chaps left a reply on How Can I Filter Recipes Based On Their Average Rating?

updated code.

$recipes = Recipe::query();

// if request has min and max
$recipes->whereHas('ratings', function($q) use ($min, $max) {
    $q->havingRaw('AVG(ratings.rating) >= ?', [$min])
         ->havingRaw('AVG(ratings.rating) <= ?', [$max]);
});
// endif

return $recipes->get();

Chaps left a reply on How Can I Filter Recipes Based On Their Average Rating?

@gregrobson tested and working! Thank you very much!

Chaps left a reply on How To Filter Min And Max Average Ratings?

thank you for the response, I need to filter the min and max average ratings of each recipe..

Chaps started a new conversation How To Filter Min And Max Average Ratings?

Hello! I am trying to filter all the recipes table with ratings, here's my current code.. thank you in advance.

$recipes = Recipe::query();

$recipes->whereHas('ratings', function($q) use ($min, $max) {
                // 1st this works.. but not in average
                // $q->whereBetween('rating', [$min, $max]);

                // 2nd
                // $q->whereBetween('AVG(rating) as rating', [$min, $max]);

                // 3rd
                // $q->select(\DB::raw('AVG(rating) as rating'))
                //     ->whereBetween('rating', [$min, $max]);

                // 4th
                // $q->whereBetween(\DB::raw("'AVG(rating)'"), [$min, $max]);
            });
18 May
2 years ago

Chaps left a reply on How Do I Make A Rank Query In Pivot Table?

currently I just do this to show the rank

@forelse ($contest->contestUsers as $rank => $user)
    <tr>
        <td>{{ $rank+1 }}</td>
    </tr>
@endforeach 

or

@php
    $rank = 1;
@endphp

@foreach ($contest->contestUsers as $user)
    <tr>
        <td>{{ $rank++ }}</td>
    </tr>
@endforeach 

Chaps started a new conversation How Do I Make A Rank Query In Pivot Table?

Can someone see my code? I'm getting a rank null. thank you.

my [email protected] method

public function show(Contest $contest)
    {
        // Retrieve all contests that have at least one approved user and..
        $contest->load(['contestUsers' => function ($q) {
            $q->wherePivot('approved', true)
                ->addSelect('*', DB::raw('@row:=@row+1 as rank'));
        }]);

    // if return contest, rank is null

        return contest;
    }

Contest model

public function contestUsers()
    {
        return $this->belongsToMany(User::class, 'contest_portfolios', 'contest_id', 'user_id')
                    ->withPivot('join_date', 'approved', 'portfolio_value')
                    ->orderBy('pivot_portfolio_value', 'desc')
                    ->withTimestamps();
    }
10 Apr
2 years ago

Chaps left a reply on Php Error While Installation Of Laravel

install mbstring?

sudo apt-get install php-mbstring

26 Mar
2 years ago

Chaps left a reply on Npm Run Dev Ends In Error

@cklester try running your command again as root/administrator

Chaps left a reply on Npm Run Dev Ends In Error

@cklester then add it in your package.json, in your terminal run,

''' rm -rf node_modules

npm install '''

25 Mar
2 years ago

Chaps left a reply on Permissions In Ubuntu

try this

https://www.techyfingers.com/lemp-stack-for-local-development/

ctrl+F search Configuring and wrapping up everything

Chaps left a reply on Npm Run Dev Ends In Error

what version of your webpack?

try to downgrade your webpack to 2.2.1

package.json

"devDependencies": {
    "webpack": "2.2.1",
  }
27 Feb
2 years ago

Chaps left a reply on Laravel Pusher

@lars6

check your cluster? make sure you define your cluster

In your config/broadcasting.php

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_KEY'),
            'secret' => env('PUSHER_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => 'eu'
            ],
        ],

or try to remove

In your bootstrap.js

encrypted: true

Chaps left a reply on Help Please?, I Want To Show All Applications If Installed_date Is Already 1 And 1/2 Month Old? Thanks!

@tisuchi thanks sir! I just change greater than to less than.

$applications = Application::where('installed_date', '<', Carbon::now()->subDay(60))->get();
26 Feb
2 years ago

Chaps started a new conversation Help Please? How Can I Published/show All Applications If Installed_date Is Greater Than 1 And 1/2 Months?

help please?, I want to published all applications if installed_date is greater than 1 and 1/2 months? thanks!

$applications = Application::all();

return $applications;
11 Feb
2 years ago

Chaps left a reply on How Do I Redirect To Different Pages After Login [not In Relation To Role]?

@jocrah

/**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected function redirectTo()
    {
    
        if (auth()->user()->isAdmin()) {
            return $this->redirectTo = '/dashboard';
        }
        
        return $this->redirectTo = '/home';
    }

https://laravel.com/docs/5.3/authentication#included-authenticating

08 Feb
2 years ago

Chaps left a reply on Login Conditions 5.4

do you have "activated" column in your users table??

Chaps left a reply on Login Conditions 5.4

this one?

$messages = [
            'email.exists' => 'The given user account is not activated?',
        ];

        $this->validate(request(), [
            $this->username() => 'required|exists:users,email,activated,1', 
            'password' => 'required'
        ], $messages);

Chaps left a reply on Login Conditions 5.4

Your custom error message is wrong,

check, https://laravel.com/docs/5.4/validation#custom-error-messages

"Specifying A Custom Message For A Given Attribute"

Chaps left a reply on Login Conditions 5.4

try this,

In LoginController

/**
     * Validate the user login request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return void
     */
    protected function validateLogin()
    {
        $messages = [
            'email.exists' => 'Account is not active!',
        ];

        $this->validate(request(), [
            $this->username() => 'required|exists:users,email,active,1', 'password' => 'required'
        ], $messages);
    }
24 Jan
2 years ago

Chaps started a new conversation Event Broadcasting Using Socket.io, Redis And Laravel-echo-server, Question About Queue Driver In Production?

I'm building a realtime app, can i just use QUEUE_DRIVER=sync or database in production?

28 Dec
2 years ago

Chaps left a reply on How To Update Props Relationships?

thanks! yours also working if I change mounted to created

created() {
    this.gameData = this.game;
},
27 Dec
2 years ago

Chaps left a reply on How To Update Props Relationships?

@jekinney

here's what I did sir, dunno if this is the good approach

in my Game.vue

I just add

data() {
    return {
        latest_fight: this.game.latest_fight
    };
},

now fight status is updating, but I'll try that.

26 Dec
2 years ago

Chaps started a new conversation How To Update Props Relationships?

Please help, how to update a props relation?

I'm trying to update fight status of the game, but it's not updating? can someone see what's missing in my code, TIA!

Game Model

/**
     * Get the fights for the game.
     */
    public function fights()
    {
        return $this->hasMany(Fight::class);
    }

    /**
     * Get the latest fight for the game.
     */
    public function latestFight()
    {
        return $this->hasOne(Fight::class)->latest();
    }

GameController

public function show(Game $game)
    {
    // Lazy Eager Loading latest fight
        $game->load('latestFight');
        
        return view('games.show', ['game' => $game]);
    }

games/show.blade.php

@extends('layouts.app')

@section('content')
<game :game="{{ $game }}"></game>
@endsection

Game.vue

<template>
<div class="row">
    <div class="col-xs-4">Status:
                        <span v-if="game.latest_fight.status == 'Waiting'" class="label label-default"> {{ game.latest_fight.status }}</span>
                        <span v-if="game.latest_fight.status == 'Open'" class="label label-primary"> {{ game.latest_fight.status }}</span>
                        <span v-if="game.latest_fight.status == 'Close'" class="label label-danger"> {{ game.latest_fight.status }}</span>
                        <span v-if="game.latest_fight.status == 'Cancel'" class="label label-warning"> {{ game.latest_fight.status }}</span>
                    </div>

    <admin-console :game="game"></admin-console>
</div>
</template>

<script>
    import AdminConsole from './Console.vue';

    export default {
        props: ['game'],


        components: { AdminConsole }
    }
</script>

Console.vue

<template>
    <div class="col-xs-5 p-0">
        <div class="col-xs-4 p-0">
            <div class="panel panel-default m-0">
                <div class="panel-heading p-0">Status</div>

                <div class="panel-body">
                    <button class="btn btn-default btn-xs btn-block" v-on:click="updateFightStatus('Waiting')">Waiting</button>
                    <button class="btn btn-default btn-xs btn-block" v-on:click="updateFightStatus('Open')">Open</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        props: ['game'],

        methods: {
       updateFightStatus(status) {
                if (status == 'Waiting') {
                    this.Status(status);
                }

                if (status == 'Open') {
                    this.Status(status);
                }
            },

            Status(status) {
                this.updateStatus = {
                    'status': status,
                }
                this.$http.patch('/api/fights/' + this.game.latest_fight.id + '/status', this.updateStatus)
                        .then(response => {
                // code to update game fight status
                                this.game.latest_fight.status = this.updateStatus.status; 
                            }
                        );
            }
        }
    }
</script>
30 Nov
2 years ago

Chaps left a reply on Please Help, Concern About Vue Production File

jeff says I can even make the 4th argument to override the default webpack config.

https://laracasts.com/series/es6-cliffsnotes/episodes/12

11:15 to 11:50

Chaps left a reply on Please Help, Concern About Vue Production File

@ejdelmonico

ok here's what I did,

I created webpack.config.js in root project

var webpack = require('webpack')

module.exports = {
    plugins: [
        // ...
        new webpack.DefinePlugin({
          'process.env': {
            NODE_ENV: '"production"'
          }
        }),
        new webpack.optimize.UglifyJsPlugin({
          compress: {
            warnings: false
          }
        })
    ]
}

then in my gulpfile.js

const elixir = require('laravel-elixir');

require('laravel-elixir-vue-2');

elixir(mix => {
    mix.sass('app.scss')
       .webpack('app.js', null, null, require('./webpack.config.js'));
});

then I run gulp --production

Now I can't not see vue error anymore, is this ok now?

Chaps left a reply on Please Help, I'm Currently Running My Website On Production

@ejdelmonico

before, my logs getting flooded

unix:/var/run/php/php7.0-fpm.sock failed Connection reset

then I modify

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

and

listen = /var/run/php7.0-fpm.sock

to

listen = 127.0.0.1:9000

now I'm getting

connect() failed (111: Connection refused) while connecting to $ upstream

but not getting flooded bad gateway.

Okay sir I'll check New Relic.

Chaps left a reply on Please Help, I'm Currently Running My Website On Production

@martinbean sadly to say, yes its 16 cpus and only 100 concurrent users

Chaps left a reply on Please Help, I'm Currently Running My Website On Production

@luceos I dunno how to configure pool sir, I've just follow server management tutorial then

I've just modify nginix.conf

worker_connections 1024;

then added this settings on forge nginix.conf

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

Chaps left a reply on Please Help, I'm Currently Running My Website On Production

@frezno

ok I manage to fix the problem,

What i did is, I modify nginix.conf and /etc/php-fpm.d/www.con

listen = /var/run/php7.0-fpm.sock

to

listen = 127.0.0.1:9000

now I'm not getting flooded bad gateway, but my problem now is my site is so slow, running 16 cpu. 48gb memory and 8tb transfer, only 100 concurrent users, i dunno what to do now >_<

Chaps left a reply on Please Help, Concern About Vue Production File

@willvincent

thank you for reply sir, can u help me how?

I'll just add NODE_ENV=production on .env?

then run glup --production?

Chaps started a new conversation Please Help, Concern About Vue Production File

On production, I'm getting full warning and debug mode, how do i toggle vue production file?

29 Nov
2 years ago

Chaps started a new conversation Please Help, I'm Currently Running My Website On Production

Please Help, I'm currently running my gaming website on production, I'm getting flooded in chrome dev tools, with error 502 bad gateway, how do i fix this?

25 Nov
2 years ago

Chaps started a new conversation How To Put Script Tag Inside Vuejs Components?

Please help? I want to put this video script tag inside vue components? can someone give me an example?

<script src="js/player.js" id="some_random_video_id" class="dacast-video"></script>
23 Nov
2 years ago

Chaps left a reply on Help Please? How To Get The Last 10 Rows Of A Table?

also tried using computed property

computed: {
    reversedMessage: function() {
        return this.posts.reverse();
    },
},
<li v-for="post in reversedMessage">
                                <div class="chat-info">
                                    <span v-show="post.user.role.label == 'General Admin'" class="name generaladmin pull-left">{{ post.user.username ? post.user.username : post.user.email }}: </span>
                                    <span v-show="post.user.role.label == 'Administrator'" class="name admin pull-left">{{ post.user.username }}: </span>
                                    <span v-show="post.user.role.label == 'Customer Service Representative'" class="name csr pull-left">{{ post.user.username }}: </span>
                                    <span v-show="post.user.role.label == 'Member'" class="name member pull-left">{{ post.user.username ? post.user.username : post.user.email }}: </span>

                                    <div class="message">
                                        {{ post.message }}
                                    </div>
                                </div>
                            </li>

Chaps left a reply on Help Please? How To Get The Last 10 Rows Of A Table?

@lindstrom thanks for your reply sir,

yes I'd tried reverse method,

public function getChatMessage(Game $game)
{
        $chatMessage = ChatMessage::with('user.role')
                              ->where('game_id', $game->id)
                              ->latest()
                              ->take(5)
                              ->get();
        $messages = $chatMessage->reverse();

        return $messages->all();
}

but vuejs doesn't render it in reverse

mounted() {
    this.getChatMessage();
},

methods: {
    getChatMessage() {
        this.$http.get('/api/message/' + this.game.id)
            .then(response => {
            this.posts = response.data;
        });
    },


    addNewMessage() {
        this.btnChat = true
        this.$http.post('/api/message/' + this.game.id,         {message:       this.newMessage})
    .then((response) => {          
            this.newMessage = '';
                        this.btnChat = false
                });
    },
}
22 Nov
2 years ago

Chaps left a reply on Laravel 5.3 Reverse Method Not Working?

UPDATE

Sorry, I think my JSON Formatter is not working as expected

when I view it in RAW format, it retuns as expected

Chaps left a reply on Laravel 5.3 Reverse Method Not Working?

strange, mine not working? laravel 5.3.18

Route::get('test', function () {
    $collection = collect([1, 2, 3, 4, 5]);

    $reversed = $collection->reverse();

    return $reversed->all();
});

Chaps left a reply on Laravel 5.3 Reverse Method Not Working?

not reversing,

same, it's returning

[1, 2, 3, 4, 5]

Chaps started a new conversation Laravel 5.3 Reverse Method Not Working?

I've created a live chat and i want to reverse my result,

$chatMessage = ChatMessage::with('user.role')
                              ->take(10)
                              ->orderBy('created_at', 'desc')
                              ->get()
                              ->reverse();

return $chatMessage;

not working as expected

$collection = collect([1, 2, 3, 4, 5]);

$reversed = $collection->reverse();

return $reversed->all();

docs says it returns,

[5, 4, 3, 2, 1]

but it is not

https://laravel.com/docs/5.3/collections#method-reverse

21 Nov
2 years ago

Chaps left a reply on Help Please? How To Select The Last 10 Rows? In Asc Order?

thanks for the reply,

just remove oldest or orderBy created asc, just the same results as this

$chatMessage = ChatMessage::with('user.role')
                 ->take(10)
                 ->get();

I want to achieve is let's say if I have 5 rows (take/limit 5)

message 1 message 2 message 3 message 4 message 5

then I'll add a new message

message 6

then if I refresh the page, I want to see in the list is

message 2 message 3 message 4 message 5 message 6