mkshingrakhiya

mkshingrakhiya

Member Since 6 Months Ago

Porbandar

Experience Points
11,840
Total
Experience

3,160 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
75
Lessons
Completed
Best Reply Awards
5
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 3
11,840 XP
Jun
05
2 months ago
Activity icon

Replied to Show Products Of Categories Of A User

You need to change it to categories.id.

Jun
04
2 months ago
Activity icon

Replied to How To Validate Client Name Field In Laravel Validation

Mark it as the best answer if it worked out for you.

Activity icon

Replied to Eloquent Query For Array

It might be because of the 0s you stored as a default value for parent_id column. Answer by @michaloravec seems good to me. It should work.

Activity icon

Replied to Eloquent Query For Array

@computermaverick I misunderstood. I'm sorry about that. I thought you wanted categories to belong to multiple.

Activity icon

Replied to How To Validate Client Name Field In Laravel Validation

You can use strip_tags() function or use the 3rd party libraries like Waavi's.

Activity icon

Replied to Eloquent Query For Array

You need to implement many to many relationship with the self to achieve what you want.

Jun
02
2 months ago
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Just comment the solution by yourself and mark it as the best answer. It will help others.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Please choose the best solution that worked out for you for this thread. Post here if you encounter other other subject related issues.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

You need to debug it step by step because if you're message showing up, then it works. You might have some other issue somewhere in your code.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Use arrow functions if you're using this inside instead of anonymous function.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

This won't have worked event it did not display because you see it displays private when event broadcasted to private channel which is handled by the server-side of the code. i.e. When we do return new PrivateChannel(...)

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Echo.private('groups.' + this.group.id)
    .listen('.NewMessage', (e) => {
        console.log(e); // What do you see here
    });
Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

What do you see when you log it into the console?

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

What does event object contain when you receive the message?

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

I think this is where your issue is. I also once stuck here. If I remember correctly, you will need to send the authentication token when it tries to authorize the channel. If you need to test if this has the problem is to try to route the request in one of the controllers which implement web middleware and remove the parameter from Broadcast::routes();.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

What is in your BroadcastServiceProvider::class?

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

When the other user joins the group, do you see any event on Pusher console?

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Whispering won't work if you're returning boolean values. You need to return some data.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

Did you authorize the channel in channels.php? In order to listen for typing event, you need to return data from the authorization instead of true.

Activity icon

Replied to VueJS Chat, Broadcasting Doesn't Seem To Be Working....

You need to prepend '.' to the listener's name if you're using broadcastAs.

Echo.private('groups.' + this.group.id)
    .listen('.NewMessage', (e) => {
        console.log(e);
    });

Did you enable client events in the Pusher settings?

One more thing I noticed is that you're listening on the private channel while you're broadcasting on the public one. Make sure to authorize if you're using private channels.

Activity icon

Replied to How Do You Sanitize User Input Data?

Hello @thebigk, Try Waavi's Sanitizer. It is easy to use and provides lots of filters.

May
30
2 months ago
Activity icon

Replied to Nginx + Php-fpm In One Dockerfile?

@gthell If you're facing issue regarding daemon:

By default, FPM will run in the background so you might need to bring it to the foreground by setting daemonize = no to the default configuration.

Activity icon

Commented on File Storage And Custom Avatars

Hey @jeffreyway, Did you change the default asset path or something else? I had to prepend 'storage' in the path.

Activity icon

Replied to Nginx + Php-fpm In One Dockerfile?

Post here if you get any problems.

Activity icon

Replied to Nginx + Php-fpm In One Dockerfile?

Dude. It has been over a year so I could not help you with the size. I don't use this setup anymore. Where do you see the redundancy in PHP installation? However, you could fetch PHP image and then on top of that install other services like Nginx and so on like @bobbybouwmann suggested.

Activity icon

Replied to Nginx + Php-fpm In One Dockerfile?

I've done it once for local development. See below. You might need to tweak it a little bit.

Dockerfile

FROM ubuntu:18.04

LABEL maintainer="Mayur Shingrakhiya <[email protected]>"

ENV DEBIAN_FRONTEND=noninteractive

# RUN apt-get update \
#     && apt-get install -y gnupg tzdata \
#     && echo "UTC" ? "/etc/timezone" \
#     && dpkg-reconfigure -f noninteractive tzdata

RUN apt-get update \
    && apt-get install -y curl zip unzip git supervisor \
       nginx php7.2-fpm php7.2-cli php7.2-curl \
       php7.2-mysql php7.2-mbstring php7.2-xml \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && mkdir /run/php \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN ln -sf /dev/stdout /var/log/nginx/access.log \
    && ln -sf /dev/stderr /var/log/nginx/error.log

ADD nginx.conf /etc/nginx/sites-available/default.conf
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ADD initial.sh /usr/bin/initial
RUN chmod +x /usr/bin/initial

ENTRYPOINT [ "initial" ]

nginx.conf

server {
    listen 80 default_server;

    root /var/www/html/public;

    index index.html index.htm index.php;

    server_name localhost;

    charset utf-8;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

    error_page 404 /index.php;
}

supervisord.conf

[supervisord]
nodaemon=true

[program:nginx]
command=nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm7.2
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

initial.sh

#!/usr/bin/env bash

##
# Ensure /.composer exists and is writable
#
if [ ! -d /.composer ]; then
    mkdir /.composer
fi

chmod -R ugo+rw /.composer

##
# Run a command or start supervisord
#
if [ $# -gt 0 ];then
    # If we passed a command, run it
    exec "[email protected]"
else
    # Otherwise start supervisord
    /usr/bin/supervisord
fi
Activity icon

Replied to Sanctum Roles & Permissions

Yeah. You could use authorization gates or model policies to better manage authorization logic. Visit the official documents for it. Then see this amazing episode to dig deeper into it and to know how efficiently you can integrate authorization into your app.

May
29
2 months ago
Activity icon

Awarded Best Reply on Select All Records With At Least 1 Related Record

You can use has() to get records with at least one defined relationship record.

$specialities = Speciality::has('groups')
    ->with('institute', 'groups')
    ->where('institute_id', '=', $id)
    ->orderBy('name', 'ASC')
    ->get();
Activity icon

Replied to Select All Records With At Least 1 Related Record

You can use has() to get records with at least one defined relationship record.

$specialities = Speciality::has('groups')
    ->with('institute', 'groups')
    ->where('institute_id', '=', $id)
    ->orderBy('name', 'ASC')
    ->get();
Activity icon

Replied to Json Response To Blade

public function test(Request $request)
{
    $today = date('Y-m-d'); // This is how you get current date
    $widgetId = $request->query('widgetId'); // This is how you get params from query
}
Activity icon

Replied to Json Response To Blade

Store it in variables like $period = '2020-05-29 - 2020-05-29; and then Arr::get($data, "{$period}.86xx3.revenue")

You could also store 86xx3 into a variable and replace literal with that variable.

Activity icon

Replied to Json Response To Blade

If you're passing JSON string, then you need to convert it back to an array. Then use {{ $data['2020-05-29 - 2020-05-29']['86xx3']['revenue'] }}

Activity icon

Replied to Json Response To Blade

return view('dashboard', [
    'data' => json_encode($data)
]);

But why do you want to pass JSON into views?

You could also pass it normally as you did in your question and then in your view, use @json($data) to convert to JSON string.

May
28
2 months ago
Activity icon

Replied to PHP Variable Mutation

It should not be doing that. You might have other issues there.

Activity icon

Replied to Accessor On Some Pages

Use accessor only when you need to. It is not necessary to define an accessory with field names only. You can name it whatever you want.

public function getShortStringFieldAttribute()
{
   return substr($this->string_field, 0, 100);
}
Activity icon

Replied to Events On Pivot

Well, I'm directly updating the pivot table so any other way would be great.

Activity icon

Replied to PHP Variable Mutation

It is maybe because you've provided additional conditions in second statement. Try dd($loans->count()); after the second statement and it might still return the original count.

Activity icon

Replied to Run Job Every Second Laravel

Why not? Create a command and inside fire the queued job.

Activity icon

Replied to Need Help With Select Statement

I presumed sponsorapp is the relationship you already defined in User model.

User::with(['sponsorapp:id'])
    ->whereHas('roles', function ($query) {
        $query->where('name', 'sponsor');
    })
    ->get(['username']);
Activity icon

Started a new Conversation Events On Pivot

How to track changes in Pivot model? Already tried closures and observers but it's not working.

Activity icon

Replied to Run Job Every Second Laravel

Another way would be with the use of shell script. The below code would fire the command and then sleep for a second. It will run in infinite loop and as @snapey already mentioned, you could also configure supervisor to start this script when the system boots.

#!/bin/bash

while true; do
  # /path/to/php /path/to/artisan command
  sleep 1;
done
Activity icon

Replied to Run Job Every Second Laravel

Change the statement like below. It will automatically execute it every second.

public function schedule(Schedule $schedule)
{
    CheckBotDelay::dispatch();
}
Activity icon

Replied to App()->getLocale() Is Always Default Locale

See the ordering of registered middlewares. Did you define it at the end?

May
27
2 months ago
Activity icon

Replied to Access MorphedByMany

I still don't see any potential errors in this code. Make sure you have proper database tables. However, App\Taggable is not required and your controller has multiple return statements. Try to follow or compare your code with the Laravel Docs.

Activity icon

Replied to How To Send Data To Pusher

You're welcome!

Activity icon

Awarded Best Reply on How To Send Data To Pusher

As I told you, through the dispatch().

PaymentStatusUpdate::dispatch($params);

Then access it in the constructor of PaymentStatusUpdate.

Activity icon

Replied to Access MorphedByMany

Could you share your controller and model here? I don't see any error in the provided code and check if $tag is an instance of Tag model first.

Activity icon

Replied to Delete Unused File

You're passing $filepath and $filename separately. You should pass $filepath . $filename as a single argument.

Storage::delete('public/avatars/' . $userFolder . '/' . $fileName);

And make sure the file exists.

Activity icon

Replied to Delete Unused File

Storage::delete() expects a full filepath.