Naysoewin

Naysoewin

Member Since 4 Months Ago

Experience Points
30,680
Total
Experience

4,320 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
278
Lessons
Completed
Best Reply Awards
0
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 7
30,680 XP
Oct
26
5 days ago
Activity icon

Replied to How To Implement Tab Param In Vue Route

Solved !!, Thanks all

Activity icon

Started a new Conversation How To Implement Tab Param In Vue Route

Hello,

I am creating SPA (Laravel + Vue ),

I just would like to know the idea or the way how to implement this small feature that i am expecting, i have done this feature on my pure Laravel blade project but i have no idea how should start on Vue (SPA)

Blade style

@empty ($tab)
@include('profiles.tabs.activities')
@else

@if (view()->exists("profiles.tabs.{$tab}"))
@include("profiles.tabs.{$tab}")
@endif
@endempty

Example : User profile will have many tab like [activities, setting and etc] , when i load user id (12) as below

localhost/users/12?tab=activities

it should render activities component , again if i load setting, it should replace with setting components without repeating others.

If possible and you could help me, please let me know how should i do or an article that i can read

Many Thanks

Oct
13
2 weeks ago
Activity icon

Replied to Get All Departments From Active Company

Yes , This is exactly what i am expecting, Thank you so much Sinnbeck.

Yes true it will have only one active company.

Activity icon

Replied to Get All Departments From Active Company

Hi, @sinnbeck ,

Thanks for reply, actually, i don't want to fetch via company with eager load . My goal is only want to get departments list from active company only ,

Yes i am hoping to get from one company only.

Thanks again

Activity icon

Started a new Conversation Get All Departments From Active Company

Hello,

Company Model hasMany departments


public function departments() {
        return $this->hasMany(Department::class);
    }

I just want to fetch all of depertments from active company, I think i make something wrong here , please help me check and thanks


public function index()
    {
        $company = Company::where('is_active', true)->get();
        return DepartmentResource::collection($company->departments()->get());
    }
Sep
23
1 month ago
Activity icon

Replied to Push An Object To Laravel Protected $with

Thank you so much Michal,

This both worked,


/**
     * The relationships to always eager-load.
     *
     * @var array
     */
    public function __construct(array $attributes = []) {
        $this->with[] = 'educations';
        
        parent::__construct($attributes);
    }

    /**
     * This method is called upon instantiation of the Eloquent Model.
     * It adds the "seoMeta" field to the "$fillable" array of the model.
     *
     * @return void
     */
    public function initializeHasManyEducation()
    {
        $this->with[] = 'educations';
    }
Activity icon

Started a new Conversation Push An Object To Laravel Protected $with

Hello,

Is it possible to push an object to Laravel eager-load protected $with = [] ?

I have User Model with own protected $with = ['post'] itself

When i use Education Trait in this User Model, I just want to append this object educations to protected $with = [] as below ,



protected $with = ['post', education'];

I tried php `array_push` , but it look like doesn't solve my requirement . Thanks all

                    
Sep
22
1 month ago
Activity icon

Replied to Factory For Model With Custom Namespace In Laravel 8

Hi @evilalex ,

I am also facing the same error , i see you fixed with above link. I am wondering if you could tell me how you fixed it with above link bro?. Thanks

Sep
06
1 month ago
Activity icon

Started a new Conversation Comment System With Parent Id

Hello,

I am try to implement this comment package in my Laravel App,

https://github.com/laravelista/comments

The packages provide to reply parent comment as tree view (child reply comment),

So, Problem here for me is , when user reply comment again and again , it look like as tree view

Like this Screenshoot => https://prnt.sc/ucendz

If possible, can anyone can explain me how can foreach all of child comment under parent comment even user reply child comment. Thanks

Like this Screenshoot => https://prnt.sc/uceoas

Aug
14
2 months ago
Activity icon

Replied to Toggle Local Avatar And Socialite Avatar

WOW,

Really Thanks for your help @bobbybouwmann

Activity icon

Replied to Toggle Local Avatar And Socialite Avatar

Hi @bobbybouwmann ,

Thank you so much ,

it's work for this two condition , (1) if user login with Social and get their image as url (2) If User doesn't have image upload we show default link gravatar.com

But , it doesn't work for if user upload manually via local server because return only avatar_path value like that

src="avatars/TzO3VaW8nSv2Al3Hz5r8J26beilnPACFAdySiDdf.png"

Could you help me check again for me? Thanks again

Aug
13
2 months ago
Activity icon

Started a new Conversation Toggle Local Avatar And Socialite Avatar

Hello,

Before it's working fine , If user doesn't have image upload , show default avatar link as below


    public function getAvatarPathAttribute($avatar)
    {
        return $avatar ? asset('storage/' . $avatar) : 'https://www.gravatar.com/avatar/';
    }

After added socialite package and someone try to login with socialite (ex.github), we request user avatar and insert to avatar_path column with full URL like that

https://avatars3.githubusercontent.com/u/62180549?v=4

So the image doesn't render anymore who login with socialite .

Browser inspect , src Url is like that src="http://localhost:8000/storage/https://avatars3.githubusercontent.com/u/62180549?v=4"

Please let me know how can i toggle it. Thanks

Aug
12
2 months ago
Activity icon

Started a new Conversation Send Notification To Multiple Roles

Hello,

1=> How to send notification to multiple roles when new Post created ? I put role name inside array but it doesn't send out to multiple roles , only send to one role that the first one of array

2=> According to docs, there is two ways to send notification via Trait and via Facade

May i know which one is better to send notification

Thanks all


public function created(Post $post)
    {
        $admin = User::whereHas('roles', function ($q) {
            return $q->whereName(['admin', 'author']);
        })->get();

        /** Using The Notifiable Trait */
        $admin->each(function ($admin) use ($post) {
            $admin->notify(new NewPostSubmitted($post));
        });

        /** Using The Notification Facade */
        Notification::send($admin, new NewPostSubmitted($post));
    }
Aug
06
2 months ago
Activity icon

Replied to Required Confirm Password Before Delete Record

Hi @jlrdw ,

Good Idea and Thanks for sharing

Hi, @bobbybouwmann , Thank you too

Activity icon

Started a new Conversation Required Confirm Password Before Delete Record

Hello,

I allowed user delete itself profile. I just want to add a security layer that user need to enter valid password before delete profile

like github , When we try to delete our repository, we do need to type repository name to delete it

or a link of Article that i can read.

Thanks

Aug
04
2 months ago
Activity icon

Replied to Set Active If Request Is Tab

Thanks again, @silencebringer

Everything solved

Activity icon

Replied to Set Active If Request Is Tab

@silencebringer ,

Thank you so much , it's work for me

One more thing, If url doesn't have any request

ex localhost:8000/username

I have Activities Tag, Setting Tag and Passowrd Change Tag

So i Just want to set a default tag (Activities Tag) as active if there is nothing request in url

Thanks again

Activity icon

Replied to Set Active If Request Is Tab

Hi, @silencebringer ,

Thanks for your helping I clearly understand the code but may be there is some issue because the page stop loading

This page isn’t working127.0.0.1 is currently unable to handle this request.

Could you please help me check again

Activity icon

Replied to Set Active If Request Is Tab

Hi @silencebringer ,

Yes I do want to set active when request()->tab is tab

If url is localhost:800/user?tab=setting set active Setting Tag

else Url is localhost:800/user?tab=change-password

then set active Change Passowrd Tag

Thanks again

Activity icon

Started a new Conversation Set Active If Request Is Tab

Hello ,

I have couple of foreach tabs. When request tab is equal tab , i just want to set active it,

Ex: localhost:800/user?tab=setting

Foreach all of exiting tabs


@isset($tabs)
      @foreach ($tabs as $tab => $action)
           a tag=> class="nav-link {{ set_active('Code Here') }}" href="{{ $action }}">{{ $tab }}
     @endforeach
@endisset

here is helper method is working fine in normal url like localhost:800/user


if (! function_exists('set_active')){
    function set_active($path, $active = 'active') 
    {
        return call_user_func_array('Request::is', (array)$path) ? $active : '';
    }
}

Thanks

Aug
03
2 months ago
Activity icon

Started a new Conversation Prevent Timestamps When Increment View_count

Hello,

Is there anyway to prevent timestamps (updated_at) when the post has increment view_count ?

If i use this in Model ,


public $timestamps = false;

I do need to assign the value every time i updated the post like that


$post->updated_at = Carbon::now();

Thanks

Jul
23
3 months ago
Activity icon

Started a new Conversation How To Get Package Path With Helper Function

Hello,

I would like to get Package Path with a helpers function because i am repeating the code again and again, when i try to access the package folder

Example I try to load package migration folder as below


$this->loadMigrationsFrom(base_path('packages/blog/database/migrations'));

What i want to do this, I just want to load the folder path via helpers function as below


// Blog is Package Name `Project folder/Packages/Blog`
$this->loadMigrationsFrom(module_path('Blog', '/database/migrations'));

In Helper Function, Please let me know how can implement the code. Thanks


if (! function_exists('module_path')) {
    function module_path($name, $path = '')
    {
        // Code Here
    }
}
Jul
22
3 months ago
Activity icon

Replied to Directory Using ../../routes/web.php

Hi Automica,

Thanks for your Reply,

I think this Global helpers functions that you mentioned are , only for Laravel main app right ?

Jul
21
3 months ago
Activity icon

Started a new Conversation Directory Using ../../routes/web.php

Hello,

Here is My Package Service Provider Directory

src/Providers/PackageServiceProvider.php

Here is My Route Directory

src/routes/web.php

This is Loading web.php from PackageServiceProvider


	$this->loadRoutesFrom(__DIR__.'/../../routes/web.php');

How Can use without ../../ as below by giving a path or Laravel Main app ->group(base_path('routes/api.php')); Route Loading, Thanks all


	$this->loadRoutesFrom(__DIR__.'/routes/web.php');
Jul
19
3 months ago
Activity icon

Replied to Target Class [CountrySeeder] Does Not Exist.

Hi Erikthiart,

Yes I am using It CountrySeeder:class

Activity icon

Replied to Target Class [CountrySeeder] Does Not Exist.

Hi Erikthiart,

Thanks for your replies, No i didn’t change ClassName, I just copy and move to my packages folder

Activity icon

Started a new Conversation Target Class [CountrySeeder] Does Not Exist.

Hello,

I am developing a package in Parent Laravel Project , Everything is working fine expect Seeder

When i move CountrySeeder to my Package's migrations/seeds Folder , I got issue in seeding

Target class [CountrySeeder] does not exist.

I tried => composer dump-autoload , composer update , php artisan cache:clear But still getting the same errors

What else i can do please ?

Thanks

Jul
18
3 months ago
Activity icon

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

Hi, @frankielee , @deepu07 ,

Thanks both of you ,

Activity icon

Started a new Conversation Call To A Member Function Posts() On Null

Hello,

I set up private $user variable

private $user;

_construct()


public function __construct()
    {
        $this->user     = auth()->user();
    }

When I create posts via user relationship, respond Call to a member function posts() on null


$post = $this->user->posts()->create($request->all());

But it's is working well if i use directly like


$post = auth()->user()>posts()->create($request->all());

I have no idea what the issue here , Thanks all

Jul
17
3 months ago
Activity icon

Replied to Eloquent Eager Loading

Hi Neeraj,

Yes I tried it, I get only name when i use select('name') But I lose Child Data like documentationGroups and other that load with Eager

Thanks again

Activity icon

Replied to Eloquent Eager Loading

Yes Neeraj,

Let me Explain again to clear with you

  1. I have Product Model , it has many documentationGroups
  2. DocumentationGroup Model also hasMany documentations

So, When i Foreach Products with Eager Loading like this


$products = Product::
        ->with('documentationGroups.documentations')
        ->get();

I just only required name column from products Table with Eager Loading datas

Like that


[
	{
		"id": 1,
		"name": "Product Name",
		"documentation_groups": [Data Here] // Eager Loading Data
	}
]
Activity icon

Replied to Eloquent Eager Loading

Hi Neeraj,

Yes When i pluck ('name') , I only get name and lost everything ,

Like that

[
	"Product One"
]

Any other ways You can help me those?

Thanks

Activity icon

Replied to Invalid Argument Supplied For Foreach()

Hi Michal,

Yes I used it before , I just try to compress query filter using eager Loading `

$productDocumentations = Product::with('documentationGroups') ->get();

Could you please let me know why i can not use eager loading, foreach , like

$product->documentation_groups`

Thanks

Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach()

Hello Please help again,

I am Product Model


	public function documentationGroups()
    {
        return $this->hasMany(DocumentationGroup::class);
    }

This is Data from Controller $productDocumentations = Product::has('documentationGroups') ->with('documentationGroups') ->get();


[
    {
        "id" : 1,
        "name": "ProductName" ,
       	 "documentation_groups": [
            {
               "id": 1,
               "product_id": 1,
               "name": "Introduction",
               "slug": "introduction",
           },
           {
            	"id": 3,
               	"product_id": 1,
                "name": "Customization",
                "slug": "customization",
           }
        ]
    }
]

When I foreach child data documentation_groups , it respond "Invalid argument Supplied for foreach()


@foreach ($products as $product)
	@foreach($product->documentation_groups as $documentationGroup)
		{{ $documentationGroup->name }}
	@endforeach
@endforeach
Jul
16
3 months ago
Activity icon

Replied to Eloquent Eager Loading

Hi Mariano,

One more Question, When i Eager Loading the products, How can i pluck 'name' only , Thanks again Like that



[
	{
		"id": 1,
		"name": "Product Name",
		"documentation_groups": [Data Here]
	}
]

Activity icon

Replied to Eloquent Eager Loading

Arr, It's working , Thank Mariano

Activity icon

Started a new Conversation Eloquent Eager Loading

Hello,

Products has Many DocumentationGroup


	public function documentationGroups()
    {
        return $this->hasMany(DocumentationGroup::class);
    }

DocumentationGroup has Many Documentation


	public function documentations()
    {
        return $this->hasMany(Documentation::class);
    }

I am trying to Eager Loading like that

$products = Product::with('documentationGroups.documentations')->get();

I just don't want to load the product if documentation_groups has Empty array


	"created_at": "2020-07-17T02:40:31.000000Z",
	"updated_at": "2020-07-17T02:40:31.000000Z",
	"deleted_at": null,
	"documentation_groups": []

Thanks

Activity icon

Started a new Conversation Undefined Method 'documentations'.intelephense(1013)

Hello,

I am using VS code and Installed intelephense Extension,

When i create documentations using user hasMany relationship like below


	$documentation = auth()->user()->documentations()->create(request()->validate([
            'title' => 'required|string|min:2|max:60',
            'documentation_group_id' => 'required|integer',
        ]));

The process is working well correctly but i am seeing the error message like this

Undefined method 'documentations'.intelephense(1013)

Am i making wrong something or any issue with Intelephenese Extension? Thanks all

Jul
15
3 months ago
Activity icon

Replied to Url Loading With Route Model Binding

Hi Snapey,

Thanks , I solved this

Activity icon

Started a new Conversation Url Loading With Route Model Binding

Hello , Sorry for a bit long Question

I am working on documentation features

I have a couple of Products and each has own documentation

Product Model


    public function documentationCategories()
    {
        return $this->hasMany(DocumentationCategory::class);
    }

DocumentationCategory Model


    public function documentations()
    {
        return $this->hasMany(Documentation::class);
    }

My Controller


public function product(Product $product)
    {
        return view('admin.documentations.product', compact('product'));
    }


    public function show($product, $documentationCategory, Documentation $documentation)
    {
        return view('admin.documentations.show', compact('documentation'));
    }

Here is My Route


Route::group(['prefix' => 'docs', 'as' => 'documentations.'], function () {
    // SIngle Product Route
    Route::get('/{product}', '[email protected]')->name('product');
    // Single Documentation Show Route
    Route::get('/{product}/{documentationCategory}/{documentation}', '[email protected]')->name('show');
});

My Question is

When i call localhost/docs/productname, It's loading well with list of Documentations with Documentation Categories like this screen shoot https://prnt.sc/ti3t4a

I am a bit confusing and no idea how can i load Single Documentation like localhost/docs/productname/docscategoryname/id in this page

Maybe i make wrong table relationship something ?

Thanks

Jul
09
3 months ago
Activity icon

Started a new Conversation Render Client Local Time

Hello,

I am trying to get Client Time and Server Local Time, I don't know why not render correctly for Client Time when i check with geo browser,

https://geotargetly.com/geo-browse


methods: {
        getNow() {
            let date = new Date();

            // Your Time            
            this.yourTime = date.toLocaleString(undefined,{ 
                timeStyle:'medium',
            });

            // Our Time            
            this.ourTime = date.toLocaleString(undefined,{ 
                timeStyle:'medium',
                timeZone: 'Asia/Yangon' 
            });
        },
    }

Thanks

Jul
08
3 months ago
Activity icon

Replied to Default User Avatar Toggle In Laravel

Hi, Michal ,

It's Solved , I missing storage/ , Thanks


public function getAvatarPathAttribute($avatar)
    {
        return $avatar ? asset('storage/' .$avatar) : 'https://www.gravatar.com/avatar/';
    }

Activity icon

Replied to Default User Avatar Toggle In Laravel

Hi Michal,

Thanks again ,

I don't why , it's still doesn't work for me , Could you please help me check again :((

URL is appear like "localhost/avatars/imagename.png/" but still not render

Jul
07
3 months ago
Activity icon

Started a new Conversation Default User Avatar Toggle In Laravel

Hello,


public function getAvatarPathAttribute($avatar)
    {
        return asset($avatar ? : 'https://www.gravatar.com/avatar/');
    }

If user avatar_path is null it render the above default link that i set but user has upload Avatar , it doesn't render anything,

Database avatar_path => avatars/ca949SyW3Yim2mB5Fkcj0iSctoMXXPspG9wx013W.png

Thanks

Jul
06
3 months ago
Activity icon

Replied to High Line Query Search Result Text

Hi Michal,

Thanks for your reply

Because of i have another query filter section like date filter, view_count filter, May be i made wrong something below , No high line anymore


return $this->builder->where('title', 'LIKE', "%$keyword%")->get()->transform(function ($item) use ($keyword) {
            $item->title = preg_replace('/('.$keyword.')/i', "", $item->title);
            return $item;
        });

need return $item or not ?

Thanks again

Activity icon

Started a new Conversation High Line Query Search Result Text

Hello,

When i input any keyword and search , I just want to high line or blold or something, for those match query result text.


protected function keyword()
    {
        $query = request()->input('keyword');

        return $this->builder->where('title', 'LIKE', "%$query%");
    }

Thanks

Jul
05
3 months ago
Activity icon

Replied to Str::limit And HTML Decode

Hi Guybrush,

Thank you so much it's worked ,

Yes i do accesor with Purify plugin as below , i don't know why doesn't work for me


public function getDescriptionAttribute($description)
    {
        return Purify::clean($description);
}

Thanks again

Activity icon

Started a new Conversation Str::limit And HTML Decode

Hello,

Please help me the way i can use Str::limit and {!! !!} together , it does't work if i Use together as below,


	{!! Str::limit($post->description, 90) !!}

Thanks

Jun
29
4 months ago
Activity icon

Started a new Conversation FadeIn & FadeOut For Flash Message

Hello,

I am on going with this Series,

https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/29

Can anyone help me how can i use fadeIn from Right Bottom for new Flash and fadeOut after end

Thanks


methods: {
            flash(data) {
                if (data) {
                    this.body = data.message;
                    this.level = data.level;
                }

                this.show = true;

                this.hide();
            },

            hide() {
                setTimeout(() => {
                    this.show = false;
                }, 3000);
            }
        }