frankielee

frankielee

Software Engineer at Kuala Lumpur

Member Since 4 Months Ago

Kuala Kangsar

Experience Points
12,360
Total
Experience

2,640 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
10
Lessons
Completed
Best Reply Awards
18
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
12,360 XP
Jul
10
12 hours ago
Activity icon

Awarded Best Reply on Set Default Engine Schema From MyISAM To InnoDB

Apologize, I didn't see that. Do you able to migrate without setting the foreign key? I think it should be unsignedBigInteger since $table->id() is Alias of $table->bigIncrements('id'). based on the documentation

$table->unsignedBigInteger('user_id');
Activity icon

Replied to Set Default Engine Schema From MyISAM To InnoDB

Apologize, I didn't see that. Do you able to migrate without setting the foreign key? I think it should be unsignedBigInteger since $table->id() is Alias of $table->bigIncrements('id'). based on the documentation

$table->unsignedBigInteger('user_id');
Activity icon

Replied to Dependent Dropdown With API

You are welcome. This is why we have a forum here =).

Activity icon

Awarded Best Reply on Dependent Dropdown With API

Based on the result of console.table(res.data);, I assumed the variable resultsis the data you want

var data = res.data.results;
 if(data.length>0){
                $("#subdistrict").empty();
                $.each(data,function(key,value){
                    $("#subdistrict").append('<option value="'+key+'">'+value+'</option>');
                });
           
            }else{
               $("#subdistrict").empty();
            }
Activity icon

Replied to Dependent Dropdown With API

Based on the result of console.table(res.data);, I assumed the variable resultsis the data you want

var data = res.data.results;
 if(data.length>0){
                $("#subdistrict").empty();
                $.each(data,function(key,value){
                    $("#subdistrict").append('<option value="'+key+'">'+value+'</option>');
                });
           
            }else{
               $("#subdistrict").empty();
            }
Activity icon

Replied to Dependent Dropdown With API

Do you mean this drop-down list?

success:function(res){               
            if(res){
                $("#districts").empty();
                $("#districts").append('<option>Select</option>');
                $.each(res,function(key,value){
                    $("#districts").append('<option value="'+key+'">'+value+'</option>');
                });
           
            }else{
               $("#districts").empty();
            }
           }

if yes, then you will have to get the correct response data from the API, try to console.table(res.data) to check the data.

success:function(res){
if(res){
console.table(res);
console.table(res.data);

}

}else{

}
Activity icon

Replied to Dependent Dropdown With API

I am not that familiar in using ajax, but normally I usually faced this issue when I am using axios, the way I handle is using the plugin https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en

Activity icon

Replied to Dependent Dropdown With API

Btw, if you are working on localhost, the fastest solution is serving the hosts in 2 different ports. Example :

  1. php artisan serve //default port is 8000
  2. php artisan serve --port=8001

Browse the website using the domain http://your domain:8000, the ajax request the API with the port 8001

Activity icon

Replied to Dependent Dropdown With API

The issue is caused by the Cors middleware, maybe you can refer to this https://laracasts.com/discuss/channels/laravel/cors-1

Activity icon

Replied to Dependent Dropdown With API

Maybe we should find out this is the Laravel issue or ajax issue first. You can add some debug logs inside the ajax function.

$('#province').change(function(){
    var provinceID = $(this).val(); 
	console.log('province id',provinceID);	
if(res){
 console.table(res)

}

etc....

Jul
09
1 day ago
Activity icon

Replied to How To Check If A URL Is An Article Or Just A Web Page?

Maybe this will work, check the content type of the header after requesting the web page

$response = $client->request('PUT', '/put', ['json' => ['foo' => 'bar']]);
echo $request->getHeaderLine('Content-Type');
Jul
08
2 days ago
Activity icon

Replied to Default Value

If you are saying the default value without requiring any input on inserting a new record, set the default value in your table schema

  $table->tinyInteger('publish')->default(1);
Activity icon

Replied to Laravel Crud Generator

There is a lot of templates available in the market, it just depends on your budget. For example https://coreui.io/laravel/#c-live-preview

Jul
07
3 days ago
Activity icon

Replied to How To Resolve "return Abort(401)" Issue

Hi @noblemfd, is this https://github.com/spatie/laravel-permission the Spatie Role Base you mentioned?

Perhaps you can do this in your blade

@can('leave_request_create',auth()->user())
<button>
Edit
</button>
@endcan
Jul
06
4 days ago
Activity icon

Replied to Trying To Get Property Of Non Object - Laravel 7

Np, perhaps you can write down the answer in case anyone else looking for the solution.

Activity icon

Replied to Trying To Get Property Of Non Object - Laravel 7

The error is Trying to get property 'beard_size' of non-object , maybe you can try

 <td>{{$pirate->beardSize['beard_size']}}</td>
<td>{{$pirate->beardColor['beard_color']}}</td>
Activity icon

Awarded Best Reply on How To Make Double Quoted

$maxage = strval(($current)->format('Y') - ($request->maxage));
$minage = strval(($current)->format('Y') - ($request->minage));
Activity icon

Replied to How To Make Double Quoted

$maxage = strval(($current)->format('Y') - ($request->maxage));
$minage = strval(($current)->format('Y') - ($request->minage));
Jul
05
5 days ago
Activity icon

Replied to Explicit Route Model Binding For A Specific Controller Method

Hi @anwarn, you can refer to this video https://www.youtube.com/watch?v=XsHgZD7tE_o model

public function getRouteKeyName(){
	return 'column_name';
}
Activity icon

Awarded Best Reply on What Grant Type Is Used In This Tutorial?

I think is personal access token.

Activity icon

Replied to 404 Not Found

Hi @jeroenvanrensen, is there a problem? Based on the documentation, you don't need to declare the target action https://laravel.com/docs/7.x/controllers#resource-controllers

Activity icon

Replied to 404 Not Found

Not sure how you triggered that error since I have declared it at the parameters o.o

public function update(Request $request, User $user <==){
dd($user);
}
Activity icon

Replied to 404 Not Found

Try to uncomment all the codes at your function, to check you are still meeting any 404.

//Rename the User $user to your model
//after that dd(your model)
public function update(Request $request, User $user ){
dd($user);
}
Activity icon

Replied to 404 Not Found

Change the function's parameters

public function update(Request $request, User $user ){

}

Activity icon

Replied to 404 Not Found

You have to name the return variable, refer to https://laravel.com/docs/7.x/routing#named-routes

 return redirect()->route("users.show", ['users'=>$id]);
Activity icon

Replied to Image Once On The Left, Once On The Right

Not sure if this meets your requirement. If the image is not null, the image width will be 50% fo the division, so every division will have only 2 pictures.

@if($subpage->singlePhotoForSubpage() != NULL)
<div class="col-6 col-md-6">

	<img class="img-fluid" src="/../storage/app/{{ $subpage->singlePhotoForSubpage()->filename }}" alt="{{ $subpage->title }}">
</div>
@endif
Jul
04
6 days ago
Activity icon

Replied to How To Exclude Employees With Special Character In Their Email In Eloquent


$employees = HrEmployee::where('company_id', $userCompany)->where('is_status', 0)
->whereNotIn('employee_number', [110,221,132])->get();
Jul
03
1 week ago
Activity icon

Replied to Strange Issue With Mailable - Unable To Pass A Collection Over

Fortunately, my answer is still partially correct to solve your issue :P.

Activity icon

Replied to Strange Issue With Mailable - Unable To Pass A Collection Over

I see. Thanks for letting me know about that.

Activity icon

Replied to I Wanna Change CamelCase Database Field Value Using Accessor In Laravel ?

@ishra Agree with you. Your points are opening my mind, maybe I am just sticking too much to snake_case, haha.

@singhwithlaravel Congratz. Just mark your answer as best reply to close the thread.

Activity icon

Replied to Strange Issue With Mailable - Unable To Pass A Collection Over

I not sure how it works, but this what I did all the time and working fine.

blade

   return redirect()->back()->with($status, $message);//actually the different thing?

View

@if (session('danger')||session('success'))
             
<div class="alert alert-{{session('danger')? 'danger' : 'success'}} alert-dismissible fade show" role="alert">
        <strong class="text-primary">{{session('danger')??session('success')}}</strong>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
         	<span aria-hidden="true">&times;</span>
	</button>
</div>
  @endif
Activity icon

Awarded Best Reply on Strange Issue With Mailable - Unable To Pass A Collection Over

   return $this->from('[email protected]')
        ->subject('xxxxxxxx Notifications')
        ->markdown('emails.emailNewsletters')
        ->with('collections' , $this->collections);

In your blade Edit: Wrong answer provided here, check the next reply.

{{session('collections')}}
Activity icon

Replied to Strange Issue With Mailable - Unable To Pass A Collection Over

   return $this->from('[email protected]')
        ->subject('xxxxxxxx Notifications')
        ->markdown('emails.emailNewsletters')
        ->with('collections' , $this->collections);

In your blade Edit: Wrong answer provided here, check the next reply.

{{session('collections')}}
Activity icon

Replied to I Wanna Change CamelCase Database Field Value Using Accessor In Laravel ?

@ishra sure, hope I can explain it well. For me, it is a kind of a duplicate job. In Laravel, one of the use cases of an accessor is to modify the value while retrieving the value.

Example

public function getFirstNameAttribute($value)
{
	//before "frankieelee"
        return ucfirst($value);
	//after "FRANKIELEE"
}

Output = {
	"first_name":"FRANKIELEE"
}

But if you want to append a new value to JSON, you will need to declare the variable $appends. Example

protected $appends =["full_name"];

public function getFullNameAttribute(){
	return "{$this->first_name} {$this->last_name}";
}

Output = {
	"first_name":"FRANKIELEE",
	"full_name":"frankielee lastname"//new attribute added
}

The solution I provided to the @singhwithlaravel case will return 2 variables containing the same value.

Example

protected $appends=['clock_in_time'];

public function getClockInTimeAttribute(){
	return $this->attributes['clockInTime'];
}
Output = {
	"clockInTime": "2020-06-26 12:35:35",
	"clock_in_time": "2020-06-26 12:35:35"
}
Jul
02
1 week ago
Activity icon

Awarded Best Reply on General Error: 1364 Field 'article_id' Doesn't Have A Default Value

You need to declare the relationships, after that In model

public function comments(){
	return $this->hasMany(Comment::class,article_id);
}

In your controller

$article->comments()->create([
            'user_id' => auth()->id(),
            'body' => request('body'),
        ]);

Edit: Refer to this https://laravel.com/docs/7.x/eloquent-relationships#one-to-many

Activity icon

Replied to General Error: 1364 Field 'article_id' Doesn't Have A Default Value

Np. If you are returning back to the same page,

	return redirect()->back();//redirect to the same page without any data
	return redirect()->back()->with("message","success");//redirect to the same page with data
Activity icon

Replied to What Grant Type Is Used In This Tutorial?

I think is personal access token.

Activity icon

Replied to I Wanna Change CamelCase Database Field Value Using Accessor In Laravel ?

A bad practice, you can do like this

protected $appends=['clock_in_time'];

public function getClockInTimeAttribute(){
	return $this->attributes['clockInTime'];
}

Activity icon

Replied to Email Is Taking So Much Time To Reach

Just like @tray2 said, it is due to server latency and network traffic.

Activity icon

Replied to Email Is Taking So Much Time To Reach

You are saying that the email took to long to reach your mailbox?

Activity icon

Replied to General Error: 1364 Field 'article_id' Doesn't Have A Default Value

@duffman88, it should be /articles/{{$article->id}}/comments with double {{ }}. Since you are using Resources route, you can write like this

//example of route name : articles.comments.store
action = "{{route('the route name',$article->id)}}";

You can check the route name by using the command php artisan route:list

Activity icon

Replied to General Error: 1364 Field 'article_id' Doesn't Have A Default Value

You need to declare the relationships, after that In model

public function comments(){
	return $this->hasMany(Comment::class,article_id);
}

In your controller

$article->comments()->create([
            'user_id' => auth()->id(),
            'body' => request('body'),
        ]);

Edit: Refer to this https://laravel.com/docs/7.x/eloquent-relationships#one-to-many

Activity icon

Awarded Best Reply on Sending To Other ID Within One Column...[Assistance]

My first thought is something like this:

$res = Feedback::where('recipient_id', '!=', user()->id)->groupBy('recipient_id')->get();

foreach($res as $re){
	//send notification here
}
Activity icon

Replied to Sending To Other ID Within One Column...[Assistance]

My first thought is something like this:

$res = Feedback::where('recipient_id', '!=', user()->id)->groupBy('recipient_id')->get();

foreach($res as $re){
	//send notification here
}
Activity icon

Replied to Laravel Passport, Force Generation Token

You can create the token by https://laravel.com/docs/7.x/passport#managing-personal-access-tokens

$user->createToken("token name", "token scope");
Activity icon

Replied to Autorefresh Div

So you want the page to fetch the latest comments every 2 minutes? Perhaps you can try to implement the WebSocket.

Jul
01
1 week ago
Activity icon

Replied to Production.ERROR: Property [is_approved] Does Not Exist On This Collection Instance

To do the condition checking on the is_approved, you will at least, implement the foreach loop to do so.