kkatwork

Member Since 1 Year Ago

Experience Points
45,350
Total
Experience

4,650 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
414
Lessons
Completed
Best Reply Awards
1
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.

  • Community Pillar

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

Level 10
45,350 XP
Dec
16
1 month ago
Activity icon

Replied to Error : Trait Is Not Found (using In Models)

Try giving the full namespace of trait directly in the use statement, like

use App\Models\Services\Permissions\Traits\HasPermissions; 
Dec
15
1 month ago
Activity icon

Replied to Error : Trait Is Not Found (using In Models)

Paste the error in detail.

Activity icon

Replied to Error : Trait Is Not Found (using In Models)

Have you tried composer dump-autoload?

Activity icon

Commented on Unit Test A Simple Class

Need a similar series on BDD.

Dec
14
1 month ago
Dec
13
1 month ago
Activity icon

Started a new Conversation How Laravel Autoloads Directories Other Than App?

Inside the composer.json in autoload section we see that

"autoload": {
	"psr-4" : {
		"App\" : "app/"
	}
}

still Laravel loads classes from database, routes, resources, storage, vendor directories.

Can anybody tell how does this work?

Dec
08
1 month ago
Activity icon

Replied to Model Doesn't Get Deleted When Using Deleting Event

I found solution, when I don't use relation in the deleting event but use DB facade then everything works. (User gets deleted and also comments)

 static::deleting(function ($user) {
            // $user->comments()->delete();
            DB::table('comments')->where('user_id', $user->id)->delete();
           DB::table('store_user')->where('user_id', $user->id)->delete(); 
        });

I wonder why it doesn't work when using comments()->delete() as expected. (User doesn't get deleted)

Activity icon

Replied to Model Doesn't Get Deleted When Using Deleting Event

And it doesn't show any error. But user is not deleted.

Activity icon

Replied to Model Doesn't Get Deleted When Using Deleting Event

User Model does is not deleted. But comments are deleted.

Activity icon

Started a new Conversation Model Doesn't Get Deleted When Using Deleting Event

Hi, deleting event works but the actual model where delete() method is being used persists in the database.

This is user controller method

public function delete(User $user)
    {
        // dd($user); 
        if (Gate::denies('delete-user', $user)) {
            return abort(403); 
        }
        // $user->stores()->detach();
        $user->delete(); 

        return redirect()->back()->with('message', "User deleted Successfully!");
    }

This is booted method on user model

protected static function booted()
    {
        static::deleting(function ($user) {
            $user->comments()->each(function($comment){
                $comment->delete();
            }); 

           DB::table('store_user')->where('user_id', $user->id)->delete(); 
        });
    }

If I don't use deleting event or do any other operation before delete then it works well and user gets deleted.

Dec
04
1 month ago
Activity icon

Replied to Notification Table Doesn't Exist Error

@michaloravec I think it uses correct connection when using $user->notify(); and default when using same user class $user->notifications; ! thanks.

Activity icon

Replied to Notification Table Doesn't Exist Error

@michaloravec this solution came to my mind. But shouldn't it work right away?

Activity icon

Started a new Conversation Notification Table Doesn't Exist Error

Hi,

I am facing a strange issue in my project.

I have a separate database for my 'users' table. I want to use notifications for the users.

class User extends Model {
protected $connection = 'myusers';
}

When creating the notification using

$user->notify(new EmailSent()); 

Laravel searches for 'notfications' table in the database where user table is located. So I migrated notifications table to the 'myusers' database.

But, when I try to get notifications of user

auth()->user()->unreadNotificatins;

This time, laravel searches for notification table in my default connection and throws table not found exception.

Why is this ? When storing notification table requires in Users connection and when reading it can't read from there? When I specify the connection property pointing to notification table in DatabaseNotifications class it works well But it should take automatically from User Model as it reads when creating new notification.

Is it a bug in Laravel? Or Am I doing something wrong

I hope question is understandable. Please answer as I don't want to edit code in vendor directory.

Dec
03
1 month ago
Activity icon

Commented on Union And Pseudo Types

Should I upgrade to php 8 now if I am working on laravel 7.2 and 8 projects?

Nov
21
2 months ago
Activity icon

Commented on The Honeypot Technique

wow ! extremely useful. Didn't know anything about this!

Activity icon

Commented on The Hue REST API

Cool stuff ! but not really useful because one need to have hardware to work on it. It would be nice to have a series on rest api without any special ingredient requirement.

Nov
12
2 months ago
Activity icon

Replied to File Not Found At Path ...

Same problem. Did you find any solution?

Oct
13
3 months ago
Activity icon

Replied to One Page Website

Use HTML and Bootstrap. Laravel is too much for this.

Oct
08
3 months ago
Activity icon

Replied to How To Filter Paginated Results?

@snapey Thanks for the reply.

I have a little complex condition. When I do it by chaining where method on eloquent I get not a number and various other errors. Can you guide me how should I do this operation please?

where(function($query){
            $query->where(((int)'items' - (int)'checked_items') - 'other_item', '>', 3);
        })
Activity icon

Replied to How To Filter Paginated Results?

@automica Thanks for reply.

I tried that. But I get error - 'paginate' does not exist. I think it is because after filtering we get a collection and paginate does not exist on collection.

Activity icon

Replied to How To Filter Paginated Results?

@aurawindsurfing Thanks for the reply.

I am trying to do such thing.

$items = $items->paginate(10);
$filtered = $items->filter( function($item) {
            if (condition) {
                return true;
            }
  }); 

Now I want to show the filtered items in view but with pagination links. I hope you got my point. Please reply.

Activity icon

Started a new Conversation How To Filter Paginated Results?

I have an application where I need to filter further the paginated results. When I apply filter method after the pagination method the view gives an error.

I can't insert the logic in sql query because it is complex enough.

How can I paginate and filter the results and pass to view so that pagination also works from there?

Any help appreciated.

Sep
06
4 months ago
Activity icon

Replied to How To Serve VIDEO Files Without Direct Access To File Link?

@bobbybouwmann I have created a controller action which returns the link to mp4 file. But how do I connect that stream with html element. If I place the route in src then it's just that route and not the mp4 source.

Sep
05
4 months ago
Activity icon

Started a new Conversation How To Serve VIDEO Files Without Direct Access To File Link?

Hello,

I want to play videos on a particular page of my website. Already implied Auth middleware.

Currently, I can copy the video source file and play it in different tab as a get request. Basically, as we use images and logos in project using assets.

But, I don't want user to copy the video source link and play video in different tab. I don't want video to be played outside of my page.

I am using html element and source property updated using javascript. How should I proceed?

Aug
02
5 months ago
Activity icon

Replied to Javascript Events Sometimes Don't Work

Is it because that element is dynamically generated? I guess, In that case it shouldn't work at all.

Aug
01
5 months ago
Activity icon

Replied to Javascript Events Sometimes Don't Work

@bugsysha Thanks for the reply! It is a single video element not multiple. The video element is dynamically added inside a modal.

Activity icon

Started a new Conversation Javascript Events Sometimes Don't Work

Hello,

In my application I am using javascript video element events like, onplaying, onpause, onstalled etc.

The problem is, these elements do not get fired everytime. It works good and after sometime it doesn't. Using the same browser. Tried in different browsers, sometimes events fire, sometimes don't.

The video elemnt is dynamically created and it is inside a modal. The modal is shown after video element is created inside it's body. This all is a part of ajax request success method of jquery.

I have tried to add event listeners after adding the dynamic html. I have also tried to attach listners immediately after document is ready.

I have attached some code..

$('#abcModalBody').empty();
    // console.log("Body emptied");
    // AJAX request
    $.ajax({
        url: '/abc/url',
        type: 'post',
        data: {transId: id},
        success: function(response){
            data = JSON.parse(response);
            if(addHtmlToModal()) {
                addVideoEventListeners();
                // Display Modal
                $('#abcModal').modal('show');
            }
        }
    })
function addVideoEventListeners() {
    video = document.getElementById('video');
    // console.log(video);
    fillItemsTime();
    if (video && firstItemsTime() > 0) {
        video.onplay = function() {
            // alert("Play event fired");
            console.log('play event fired');
        }
        video.onplaying = function() {
            startDisplay();
        }

        video.onpause = function() {
            // console.log("Paused");
            clearTimeout(timer);
        }

        video.onwaiting = function() {
            // console.log("waiting event fired");
            clearTimeout(timer);
        }

        video.onstalled = function() {
            clearTimeout(timer);
        }

        video.onseeking = function() {
            // console.log("seeking");
            clearClassesOfAllRows();
            clearTimeout(timer);
        }

        video.onended = function() {
            index = 0;
            clearClassesOfAllRows();
        }
    }
    // console.log("Before play");
    video.oncanplaythrough = function() {
        // console.log("video can be played now");
        $('#video').get(0).play();
    }
}