andiliang

andiliang

Member Since 1 Month Ago

Experience Points
51,310
Total
Experience

3,690 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
476
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.

Level 11
51,310 XP
Oct
28
3 days ago
Activity icon

Commented on Building Data-Tables With Livewire

he has a enhanced version datatable but need sponsorship to watch.

Oct
25
6 days ago
Activity icon

Commented on Log In With GitHub

@drehimself I can get the query string {error} check if it exists , if exisit redirect to our login page

but if we do that , if other provider return error message to our callback that does not include query string {error} .

meaning we have to handle it seperately. meaning we have to create a controller for guthub , create another controller for facebook etc.... any elegant way to handle it thanks

Activity icon

Commented on Log In With GitHub

Hi @drehimself greate lesson.

I found out one problem , after we redirect user to github landing page , user can choose to authorize or cancel . no problem if user click authorize.but problem its when user click cancal.

github will redirect user to our reidrect url . but in our handleProviderCallback method we are tring to call github api we get 401 error and print on our screen.

GuzzleHttp\Exception\ClientException
Client error: `GET https://api.github.com/user` resulted in a `401 Unauthorized` response: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}

because we are trying to call github api on this one $provider_user = Socialite::driver($provider)->user();

i try to use try catch but did not work , can you please provide a better work around for this thaks


    public function handleProviderCallback($provider)
    {
        try{

            $provider_user = Socialite::driver($provider)->user();


            $user = User::findOrCreate(
                [ 'username' => $$provider_user->getNickname() ],
                [ 'email' => $$provider_user->getEmail()  ],
                [ 'provider_id' => $$provider_user->getId(),  ]
            );


            auth()->login($user);

            return view('loggedin' );

        }

        catch(Exception $e) {
          return redirect('/login');
        }


    }

it also happens to livewire screencast github button if I click cancel. hehe @calebporzio

Oct
24
1 week ago
Activity icon

Commented on Use Third-Party Providers

if a user register in our laravel app , with password, and tmrw he register with github same email , after he come to our laravel app using the github login , we cant create the user in our db right ,

because when he first register with laravel , the provider_id will set to null. then in the firstorcreate method we cant find the provider_id we will create the user , but the user email is the same as our db current table. so there is a onstrain violation ?

will this be good we will create a seperate table for oauth login user , set the provider_id to unique field even the user with the same email in google facebook and other a thoudson provider we will create user for them ? @drehimself thanks for the greate video (bow)

Oct
20
1 week ago
Activity icon

Started a new Conversation Alpine Flash Component

Hi I want to implement a alpine coment which will dispear after 3000ms .

@props([
    'type' => 'success',
    'colors' => [
        'success' => 'bg-green-400 border-green-500',
        'error' => 'bg-red-400 border-red-500',
        'warning' => 'bg-orange-400 border-orange-500'
    ]
])

    




<section
x-data="{ show: true }"
x-show.transition.opacity="show"

x-init="  setTimeout(() => show = false, 3000)  "
{{ $attributes->merge(['class' => "{$colors[$type]} fixed top-0 right-0 mt-4 mr-4  rounded-full px-3 py-3 text-xl font-bold  text-white "]) }}

>
    <div class="flex justify-between">
        <p>
            {{ $slot }}
        </p>



    </div>
</section>

that is workign fine . but component is not showing for the second time

this is how I use it

@if( session()->has('subscribe_success')   )
	{{ session('subscribe_success') }}
	<x-flash type="success">
		{{ session('subscribe_success') }}
	</x-flah>
@endif

it only shows the first time , second time wont show up , but I can see the $slot I pass its there , the component is inside the dom , but style is hidden. any ideas ?

I want to everytime I submit the form it gives me the flash after 3 second dispear , then another submission the form give me flash again.but currently the secodn time isnot showing I try to set show== true after settimeout function but noluckt at all

thanks any help will be appreciated !

Oct
19
1 week ago
Activity icon

Commented on The Confusing Realm Of CSS Masking

really greate content

Oct
17
2 weeks ago
Activity icon

Replied to Native App Not Install Safari Giving Error

its just a random number @bugsysha

Oct
16
2 weeks ago
Activity icon

Started a new Conversation Native App Not Install Safari Giving Error

Hi All, I have a button that launch whatsapp when user enter in web mobile view if user had INSTALLED the app without any issues, if user not install the app the browser for example safari will give error like address not found etc....

are there any turn around for this ? what I want is giveing user a nice alert or anything what other developer do ? thanks

this is how I launch whatsapp deep link

<a target="_blank" href="whatsapp://send?phone=6199577018298" >
Oct
14
2 weeks ago
Activity icon

Replied to Vue Js Flash Component Not Working When Npm Production Works Npm Run Dev

after few days of thinking , I just reliaze this morning , maybe it caused by purgecss , because in production I used it minimize tailwind css

Don't use string concatenation to create class names

<div :class="text-{{ error ? 'red' : 'green' }}-600"></div>
Do dynamically select a complete class name

<div :class="{{ error ? 'text-red-600' : 'text-green-600' }}"></div>

issue is above @sinnbeck @bobbybouwmann thanks all

Oct
12
2 weeks ago
Activity icon

Replied to Get Minimum Value From Second Table In Laravel Using Relation

hi @rocks3621 i just test my method is working , what kind of relation between product and price ? from your code your product is belongs to a price.

product model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use HasFactory;
    protected $appends = ['min_price'];

    public function price()
    {
    	return $this->belongsTo(Price::class);
    }


    public function getMinPriceAttribute()
    {
    	// return 100; 
        return  $this->price()->where('type', 1)->exists() ? $this->price->price  : null ;
	//go to the relationship product list is belong to price so product only has one price
	//here we check if product in price table type = 1 if yes , return its price
    }
}

price model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Price extends Model
{
    use HasFactory;

}

migration file

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->foreignId('price_id')->constrained()->onDelete('cascade');
            $table->string('name');
            $table->timestamps();
        });
    }

    public function up()
    {
        Schema::create('prices', function (Blueprint $table) {
            $table->id();
            $table->decimal('price', 8, 2);
            $table->bigInteger('type');
            $table->timestamps();
        });
    }

ur relationship is a product belongs to a price , so inside product table there should be a price_id , price is the parent product is the child

how I retrieve it ?

route::get('min-price', function(){

	$product = Product::find(1);
	return $product ;
	// return dd($product->price->type);


});

my record inside my product table is

INSERT INTO `products` (`id`, `price_id`, `name`, `created_at`, `updated_at`) VALUES
(1, 1, 'product1', '2020-10-12 05:37:47', '2020-10-12 05:37:47'),
(2, 2, 'product2', '2020-10-12 05:37:47', '2020-10-12 05:37:47');

price table

INSERT INTO `prices` (`id`, `price`, `type`, `created_at`, `updated_at`) VALUES
(1, '100.00', 1, '2020-10-12 05:37:18', '2020-10-12 05:37:18'),
(2, '200.00', 2, '2020-10-12 05:37:18', '2020-10-12 05:37:18'),


result I get from the route


{
"id": 1,
"price_id": 1,
"name": "product1",
"created_at": "2020-10-12T13:37:47.000000Z",
"updated_at": "2020-10-12T13:37:47.000000Z",
"min_price": "100.00",
"price": {
"id": 1,
"price": "100.00",
"type": 1,
"created_at": "2020-10-12T13:37:18.000000Z",
"updated_at": "2020-10-12T13:37:18.000000Z"
}
}

does this solve your problem ??

Oct
11
2 weeks ago
Activity icon

Replied to Get Minimum Value From Second Table In Laravel Using Relation

hi if i were you , i will make a method inside product list model , using the getter.

    public function getMinPriceAttribute()
    {
        return  $this->PriceVal()->where('type', 1)->exists() ? $this->PriceVal->price  : null ;
	//go to the relationship product list is belong to price so product only has one price
	//here we check if product in price table type = 1 if yes , return its price
    }

fianlly append it

protected $appends = ['min_price'];

https://laravel.com/docs/8.x/eloquent-serialization#appending-values-to-json

I am not sure if the code works its just my person opinion. I kniw there is more smart to do .thanks

Oct
10
3 weeks ago
Activity icon

Replied to Vue Js Flash Component Not Working When Npm Production Works Npm Run Dev

hi thanks for responding , the flash method is living inside the component

<script>
    export default {
        props: ['message'],
        data() {
            return {
                body: this.message,
                level: 'success',
                show: false
            }
        },
        created() {
            if (this.message) {
                this.flash();
            }
            window.events.$on(
                'flash', data => this.flash(data),
                console.log('vue js flash created22')
            );


        },
        methods: {
            flash(data) {
                if (data) {
                    this.body = data.message;
                    this.level = data.level;
                }
                this.show = true;
                this.hide();
            },
            hide() {
                setTimeout(() => {
                    this.show = false;
                }, 3000);
            }
        }
    };
</script>

that should not be the issue , since dev env is working.

Activity icon

Started a new Conversation Vue Js Flash Component Not Working When Npm Production Works Npm Run Dev

Hi all , The vuejs inside the forum episode https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/29

is not working when I run npm run production , but its working when I run npm run dev or watch

does any one has any ideas on this ? thanks

this is how my app.js look like

require('./bootstrap');

window.Vue = require('vue');


Vue.component('flash', require('./components/Flash.vue').default);

window.events = new Vue();

window.flash = function (message, level = 'success') {
    window.events.$emit('flash', { message, level });
};

let app = new Vue({
	el: '#app',
});

how I reder it

<flash message="{{ session('flash') }}"></flash>

my package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.19",
        "cross-env": "^7.0",
        "laravel-mix": "^5.0.1",
        "laravel-mix-purgecss": "^5.0.0",
        "lodash": "^4.17.19",
        "resolve-url-loader": "^3.1.0",
        "vue-template-compiler": "^2.6.12"
    },
    "dependencies": {
        "algoliasearch": "^4.5.1",
        "dropzone": "^5.7.2",
        "instantsearch.js": "^4.8.3",
        "tailwindcss": "^1.8.10",
        "trix": "^1.3.0",
        "turbolinks": "^5.2.0",
        "vue": "^2.6.12",
        "vue-instantsearch": "^3.4.1",
        "vue-turbolinks": "^2.1.0",
        "vuex": "^3.5.1"
    }
}

my component :

        created() {
            if (this.message) {
                this.flash();
            }
            window.events.$on(
                'flash', data => this.flash(data),
                console.log('vue js flash created22')
//in production env , the console .log is working , I do not even know why the flash message its not working 
            );


        },

in production env , the console .log is working , I do not even know why its not working the flash message any help will be highly appreciated !

Activity icon

Commented on Meet Teamsy

Its the new instructor boss Jeffrey hired recently hahaha

Activity icon

Commented on Flash Messaging With Vue

Hi bro and sis ,

good day,

this vuejs flash component I just released its not working when I run npm production even in LOCAL env , does anyone have any ideal why ? works well if I run npm run dev or npm run watch

thanks

Oct
09
3 weeks ago
Activity icon

Replied to Laravel And NGINX All Routes Not Found

this is great finding !!

Oct
06
3 weeks ago
Activity icon

Replied to Laravel Got Stuck After Login. Laravel 5.8

same issues here using laravel 8.something firefox np at all.

Sep
23
1 month ago
Activity icon

Awarded Best Reply on Traverse Models In Multiple Levels Using Laravel's Eloquent

hi yes you do it

look like you are looking for hasmany through relashiption

official doc https://laravel.com/docs/8.x/eloquent-relationships#has-many-through

let sy table a is contry , table b is use , table C is post ,

a contry has many user , a user belongs a contry a user has many post , a post belong to a user

in contry model you can do this :

class Country extends Model { /** * Get all of the posts for the country. */ public function posts() { return $this->hasManyThrough('App\Models\Post', 'App\Models\User'); } }

example above from laravel thanks

Activity icon

Replied to From CakePHP 2 To Laravel 8

hi ,

yes you have to create your route , then route link to your controller. well i remember codeigniter does not requre create own route.

middleware is like a extra layer before the request hit your application , for example you can create middleware to check if a logined user is admin. it just a extra layer implement before hit your endpoint. you can check many other things and decide give error or not.

thanks

Activity icon

Replied to Anonymous Users After Deleting Account

hi maybe you can use softdelete , when user delete their acct , we use soft delete , then when render the soft deleted user acct replace with "Anonymous User"

Activity icon

Replied to Traverse Models In Multiple Levels Using Laravel's Eloquent

hi yes you do it

look like you are looking for hasmany through relashiption

official doc https://laravel.com/docs/8.x/eloquent-relationships#has-many-through

let sy table a is contry , table b is use , table C is post ,

a contry has many user , a user belongs a contry a user has many post , a post belong to a user

in contry model you can do this :

class Country extends Model { /** * Get all of the posts for the country. */ public function posts() { return $this->hasManyThrough('App\Models\Post', 'App\Models\User'); } }

example above from laravel thanks

Activity icon

Commented on Thread Subscriptions: Part 5

I had found a small bug now , when we create notification we store the 'link' => $this->reply->path() where later in notification component we retrieve it and pass to notification link, where user will click .

but we have pagination in place on the thread reply component. if the reply is in page 2 and that 'link' => $this->reply->path() wont work

what I am thinkg is we need to pass the pagination link to notification db , instead 'link' => $this->reply->path() , but how Can We get a pagiantion link in this case ?

thanks

please kindly let me know if you guys have hinds for this thanks

Sep
22
1 month ago
Activity icon

Commented on A New Reply Component

please notice that in thread.php model

in addReply menthod , we did not return the result however ,

now we need to return the result . it takes me like 15 mins to find out , becuase the ajax has no reponse , but data is added to db thanks

on video 5:15

public function addReply($reply) { $this->replies()->create($reply); .// change to below return $this->replies()->create($reply); }

Activity icon

Commented on A Vue Reply Component

inline-template was removed from latest vue 3 , you may using what the official doc provide

https://v3.vuejs.org/guide/migration/inline-template-attribute.html#_2-x-syntax

Sep
13
1 month ago
Activity icon

Commented on Goodbye And Next Steps

good job bro

Sep
11
1 month ago
Activity icon

Commented on Construct The Profile Page

hi can make the course comment section order by latest() ?

haha newest comment always come from the bottom

Activity icon

Commented on Build A Following

the follows table scheme can be written like this

    Schema::create('follows', function (Blueprint $table) {
        $table->primary(['user_id', 'following_user_id']);
        $table->foreignId('user_id')->constrained()->onDelete('cascade');
        $table->foreignId('following_user_id')->constrained('users')->onDelete('cascade');
        $table->timestamps();
    });
Sep
10
1 month ago
Activity icon

Commented on Jetstream

wow that is the only word I leave after this Jetstream