coolpraz

coolpraz

Member Since 4 Years Ago

Kathmandu

Experience Points 75,960
Experience Level 16

4,040 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 810
Lessons
Completed
Best Reply Awards 1
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

10 Mar
2 months ago

coolpraz left a reply on Laracasts Web Site

hosted by Laravel Forge which run LEMP(Linux Nginx Mysql and PHP), Linux is Ubuntu LTS version. Laravel Forge is similar to Homestead environment. you can check Laravel homestead

https://laravel.com/docs/5.8/homestead

you can check all the script to build homestead environment

https://github.com/laravel/homestead

you can use similar environment in your server by running this bash script

https://github.com/laravel/settler/blob/v7.1.0/scripts/provision.sh

coolpraz left a reply on Event Got Fired Twice

@STEPHENLOKY - When i remove Listener even only get triggered once but the problem is i need to listen to the event that created by the core of Laravel Spark and on Listener handle method i need to fire another event which broadcast on secure channel that frontend (Vue and Laravel Echo) need to listen which update DOM in realtime. As i said before Core event of laravel only fire event not broadcast it on any channel.

09 Mar
2 months ago

coolpraz started a new conversation Event Got Fired Twice

In my app i want to make notification realtime which Laravel Spark don't ship in default installation. Whenever a notification created Laravel Spark fire NotificationCreated event.

Laravel\Spark\Events\NotificationCreated

i have setup listener in my app to listen to this event and fire my own custom event

public function handle(NotificationCreated $event)
{
    dump('done');
    event(new AbcNotificationCreated($event));

    return false;
}

This is my AbcNotification

<?php

namespace App\Events;

use App\Task;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class AbcNotificationCreated implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $notification;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($notification)
    {
        $this->notification = $notification;

        $this->dontBroadcastToCurrentUser();
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('notification');
    }
}

By default Spark don't Broadcast NotificationCreated event on any channel so i have to create my own custom event which broadcast notification for frontend to listen and react in realtime.

But the problem is AbcNotificationCreated event got fired twice. PS: Any help or suggestion appreciated

07 Mar
2 months ago

coolpraz left a reply on Spark: Can't Get The Base Mixins Value

i figured out myself, its because the mounted call when vue is loaded but the problem is its inline template and data is passed through props so we must use updated() instead of mount(), updated() is called after inline view template is render

var base = require('navbar/navbar');

Vue.component('spark-navbar', {
    mixins: [base],

    updated() {
        console.log(this.notificationsCount);
    },
});

coolpraz started a new conversation Spark: Can't Get The Base Mixins Value

i want to get the base mixins props value in a component


var base = require('navbar/navbar');

Vue.component('spark-navbar', {
    mixins: [base],

    mounted() {
        console.log(this.unreadNotificationsCount);
    },
});

i get the value 0 where in vue dev tools the value is unreadNotificationsCount is 1

25 Jun
1 year ago

coolpraz left a reply on Where Are You All From?

Kathmandu, Nepal

10 Apr
2 years ago

coolpraz left a reply on Is It Okay To Use Laravel Passport For Small Projects

@willvincent

if simple code or simple methods works then why use an extra packages, but if it is mandatory then we can go for it.

coolpraz started a new conversation Is It Okay To Use Laravel Passport For Small Projects

Is it fine to use laravel passport for just grabbing data or posting data from frontend.

28 Mar
2 years ago

coolpraz left a reply on Laravel Api Route Redirect To /home Route

Solved by problem by 1st choice

@Terrylow88 thank so much for your time.

coolpraz left a reply on Laravel Api Route Redirect To /home Route

hey @Terrylow88

i m using https://github.com/ConsoleTVs/Charts package and in documentation section it's says

Charts::realtime(url('/path/to/json'), 2000, 'gauge', 'google')
            ->values([65, 0, 100])
            ->labels(['First', 'Second', 'Third'])
            ->responsive(false)
            ->height(300)
            ->width(0)
            ->title("Permissions Chart")
            ->valueName('value')
        ->render();

i m consuming json in url section of Charts

coolpraz left a reply on Laravel Api Route Redirect To /home Route

@Terrylow88 first of all thanks for your reply,

i believe that laravel passport is use when your application expose api for third party integration and provide secure auth for accessing data of application for third party use.

however, my needs is building dashboard where in dashboard there will be chart about application usages and visitor count.

where chart receive json values from api that i define in routes/api.php but i don't want to expose api to unauthenticated user but for only admin of application so i used 'auth:api'.

Furthermore, in layout.blade.php i put this two line

<meta name="csrf-token" content="{{ csrf_token() }}">

<script>
        window.Laravel = <?php echo json_encode([
            'csrfToken' => csrf_token(),
        ]); ?>
</script>

i think this two line send token to the server from frontend. So where i missed

Thanks in advance,

27 Mar
2 years ago

coolpraz left a reply on Laravel Api Route Redirect To /home Route

@Terrylow88 how to pass api token in laravel 5.4, or i have to use laravel passport

coolpraz left a reply on Laravel Api Route Redirect To /home Route

@Speedy11 yes i tried that in local and i m using ubuntu and laravel valet. I also update APP_URL in .env file.

coolpraz started a new conversation Laravel Api Route Redirect To /home Route

Route define under routes/api.php always redirect to /home route in Laravel 5.4 instead returning json output.

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
23 Jan
2 years ago

coolpraz started a new conversation Cant Validate Otf Format

i made a form to upload fonts on server and i put validation rule only accept file with .ttf and .otf extension and its working with .ttf format but when i upload .otf extension file format the validation fails.

$this->validate($request, [
            'title' => 'required',
            'font_file' => 'required|mimes:ttf,otf'
        ]);

I'm using Laravel 5.3

21 Jan
2 years ago

coolpraz started a new conversation Those Who Are Looking Laravel Valet For Windows

Now, for window can use laravel valet in windows operating system. There is cool package develop by https://github.com/cretueusebiu for windows. here's the link to the package

https://github.com/cretueusebiu/valet-windows

follow the instruction and you will be running laravel valet full feature successfully in windows

03 Jan
2 years ago

coolpraz started a new conversation Validation Rule Of Edit File Upload In Storage

I have font database table where i store information about fonts and in controller i validate it before store to database like mime type, title. However, when i want to update the information about font how to validate it. Below is the list i want to validate on update on validation

  1. If file exists on storage
  2. If new file uploaded by form check its mimes type
  3. Don't required in validation rule if its already exists in storage and database column 'path'
01 Jan
2 years ago

coolpraz left a reply on How To Get Total Count Of Table By Using Two Value Of Column

Skimming details in laravel docs i have found the solution.

$this->medias()->whereIn('gender', ['male', 'unisex'])->count()

coolpraz started a new conversation How To Get Total Count Of Table By Using Two Value Of Column

I have a column name gender, where 3 values are stored ('male','female','unisex'). What i want is count record of column gender using value male and unisex or female and unisex.

Here's code i tried but didn't work

$this->medias()->where('gender', ['male', 'unisex'])->count()

coolpraz left a reply on Eloquent OnDelete('cascade') Does Not Trigger Extended Delete Method On Model

@jekinney

I have updated the Post model extended delete() method.

public function delete()
{
    Storage::disk('public')->delete($this->image);

    $this->medias()->delete();

    parent::delete();
}

Media.php

public function delete()
    {
        dd('ok');
        Storage::disk('public')->delete($this->path);

        parent::delete();
    }

i add dd('ok') to check whether its triggering extended delete method on media model.

The result is script won't stop with "ok" message, it means it does not trigger extended delete method on media model.

I tested it with observer the result is same as above.

31 Dec
2 years ago

coolpraz left a reply on Eloquent OnDelete('cascade') Does Not Trigger Extended Delete Method On Model

@jekinney

Thanks for the reply but i have tried that in Post model. Here's the code

Post.php

public function medias()
{
    return $this->hasMany('App\Media');
}

public function delete()
{
    $this->medias()->delete();

    parent::delete();
}

Media.php

public function post()
{
    return $this->belongsTo('App\Post');
}

public function delete()
{
    Storage::disk('public')->delete($this->path);

    parent::delete();
}

The code above dosen't solve my problem. Images is still there

30 Dec
2 years ago

coolpraz started a new conversation Eloquent OnDelete('cascade') Does Not Trigger Extended Delete Method On Model

I have two table with relation of one to many(post, media). Post table is where all post is saved and media table is where all post related to the media is saved and also store images file in disk.

On Media migration

$table->integer('post_id')->unsigned()->index()->nullable();
$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');

What my problem is when i delete post, media record is deleted on database but image file on disk didn't get deleted

I have extended delete method in Media table

public function delete()
{
    Storage::disk('public')->delete($this->path);

    parent::delete();
}

What i think is onDelete('cascade') does not trigger this extended delete method on media.

22 Dec
2 years ago

coolpraz left a reply on How To Get Uploaded File Name In Laravel 5.3

Thank you @ctroms that's solved my problem.

coolpraz left a reply on How To Get Uploaded File Name In Laravel 5.3

@maxnb @ctroms

getClientOriginalName() return the name of the image to be uploade not the name of image which is already uploaded by this line.

$path = $request->image->store('media', 'public');

above line of code upload the image into disk and automatically generate name of image using MD5 hash

Refer to documentation of Laravel 5.3: https://laravel.com/docs/5.3/requests#storing-uploaded-files

and what i want is get automatically generated image name.

coolpraz left a reply on How To Get Uploaded File Name In Laravel 5.3

@Snapey @JeffreyWay

yea, but i want to generate image name automatically, I want laravel to return whole image object instead of just path string and that will be more flexible to work with.

coolpraz left a reply on How To Get Uploaded File Name In Laravel 5.3

@ctroms

with

$path = $request->image->getClientOriginalName();

you can get image name to be uploaded

but in laravel 5.3 image name converted into md5 hash and saved to disk, the name will be something like this "df91c54c4ad5d78f43704f71d256a5e9.jpeg". My concern is how can i get saved file name in laravel 5.3

coolpraz started a new conversation How To Get Uploaded File Name In Laravel 5.3

How to get uploaded file name after file was uploaded in laravel 5.3

$path = $request->image->store('media', 'public');
09 Dec
2 years ago

coolpraz left a reply on Using Vuejs With Jquery Ui Draggable And Resizable

I tried jQuery with vue js. I used Vue js as a reactive around jQuery UI draggable and resizable, but the problem is i can't drag object and can't resize them.

I have been throw some stackoverflow question

http://stackoverflow.com/questions/35234754/vue-js-jquery-ui-draggable

http://stackoverflow.com/questions/38382125/vue-js-and-jquery-draggable-not-working

http://stackoverflow.com/questions/35374904/draggable-with-vue-js-not-being-able-to-return-to-original-position

08 Dec
2 years ago

coolpraz left a reply on Call To A Member Function Connection() On Null

comment or delete DB_CONNECTION in .env file on your laravel app root

coolpraz left a reply on Using Vuejs With Jquery Ui Draggable And Resizable

@phpMick can u show us how you integrate jquery ui draggable or resizable in your app if u did it.

07 Dec
2 years ago

coolpraz left a reply on Using Vuejs With Jquery Ui Draggable And Resizable

@willvincent isn't ready and mounted method are same, before vue2 it was ready and after release of vue js 2 it was changed to mounted

04 Dec
2 years ago

coolpraz started a new conversation Using Vuejs With Jquery Ui Draggable And Resizable

Is there any jQuery UI draggable and resizable like in Vuejs. If not how can i use jQuery UI Draggable and resizable with Vuejs

coolpraz started a new conversation When Will Spark Demo Application Update To New Version?

I'm new to spark and want to learn using it, so i went to spark documentation. The Demo application in documentation is old version of Laravel, Spark and also Vue.

24 Nov
2 years ago

coolpraz left a reply on Where Are You All From?

Kathmandu, Nepal

coolpraz left a reply on Is Laravel 5.2 Free

@topspin it depends on project. However, Laravel framework is completely free of cost but other laravel service is not free like envoyer, Spark, Forge. If your project is using those service definitely money goes to Laravel.

Furthermore, the project which use Legacy code or out of date code, upgrade to new code or change to new framework or new framework version is time consuming, and also lot of work. If your developer is asking money for those thing (envoyer, Spark, Forge, change legacy code) is completely legitimate.

13 Sep
2 years ago

coolpraz left a reply on Redirected To Show On Deleting Object

try

{{ route('myproducts.destroy', $product->id) }}
04 Jul
3 years ago

coolpraz left a reply on Can't Return Custom Exceptions

@skliche is there any hack to solve problems like this, because i want to return custom exception rather than PHP fatal error

coolpraz started a new conversation Can't Return Custom Exceptions

Can't return custom exceptions message by using below code

try {
    app("Illuminate\Contracts\Broadcasting\Broadcaster");
} catch (Exception $e) {
    dd('woops?');
}

Instead getting

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Pusher' not found
03 Jul
3 years ago

coolpraz left a reply on Service Container Debug

cant return custom exception im still getting

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Pusher' not found
01 Jul
3 years ago

coolpraz left a reply on Service Container Debug

@kfirba

still getting

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Pusher' not found

using this code

public function resolveService()
    {
        try {
            $this->laravel->make("Illuminate\Contracts\Broadcasting\Broadcaster");
        } catch (Exception $e) {
            dd('woops?');
        }
    }

coolpraz started a new conversation Service Container Debug

Im developing package Service Container debug, but i'm stuck on this line

class ContainerDebug extends Command { public function resolveService() { dd($this->laravel->make("Illuminate\Contracts\Broadcasting\Broadcaster")); } }

i want to catch class not found exception