kundefine

kundefine

Laravel Developer at ColourSpray

Member Since 2 Years Ago

Dhaka

Experience Points
2,420
Total
Experience

2,580 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
3
Lessons
Completed
Best Reply Awards
2
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 1
2,420 XP
Jul
28
3 months ago
Activity icon

Replied to Assign Same Value In The Vue Data Doesn't Change In The Dom

doesn't trigger an update. the same problem, the same value doesn't update

Jul
26
3 months ago
Activity icon

Replied to Assign Same Value In The Vue Data Doesn't Change In The Dom

by default in the view i want to show the default setting if the setting is null. if the user change the default setting and setting_value is valid then it will show the setting value in the contenteditable span. but if the setting value is invalid it will show the default value again.

here is the response can be

{
created_at: null
id: 1
// currently has the default value in the span and response setting_value is null and setting_default_value is the same as before that why when i assign with response value to the data its doesn't detect the change and doesn't change the span with the setting_default_value.
setting_default_value: "10,5,1" 
setting_name: "User Registration Bonus"
setting_value: null // setting value doesn't change
updated_at: "2020-07-27T06:21:22.000000Z"
},
{
created_at: null
id: 1
setting_default_value: "10,5,1"
setting_name: "User Registration Bonus"
setting_value: "20,30,40" // setting value change and also change in the view
updated_at: "2020-07-27T06:21:22.000000Z"
}

<tr v-if="settings.length > 0" v-for="setting in settings">
    <td class="font-weight-bold">
        @{{ setting.setting_name }}
    </td>

    <td class="vertical-align-middle">
        <span
            contenteditable="true"
            class="mr-5 admin-change-setting"
            v-bind:name="setting.setting_name"
            @blur="changeAdminSettings"
            v-text="setting.setting_value !== null ? setting.setting_value : setting.setting_default_value"
        >
        </span>
        <i class="fa fa-pencil pull-right"></i>
    </td>
</tr>                      	
asettings = new Vue({
    el: '#adminSettings',
    data: {
        settings: [{
            created_at: null
            id: 1
            setting_default_value: "10,5,1"
            setting_name: "User Registration Bonus"
            setting_value: null
            updated_at: "2020-07-27T06:21:22.000000Z"
        }]
    },
    methods: {
        changeAdminSettings  (evt) {
            let settingName = evt.target.getAttribute('name');
            let settingValue = evt.target.innerText;
            axios({
                method: 'patch',
                url: window.settingUpdateUrl,
                data: {
                    settingName,
                    settingValue
                }
            }).then(response => {
                for (let i = 0; i < this.settings.length; i++) {
                    if(this.settings[i].setting_name === response.data.setting_name) {
                        this.settings[i].setting_value = response.data.setting_value;
                        this.settings[i].setting_default_value = response.data.setting_default_value;
                        
                          if(this.settings[i].setting_value === null) {
                            // over here i have to modify the DOM manually because the response setting_default_value data is same that's why its doesn't detect the change in the and never update the view
                            evt.target.innerText = response.data.setting_default_value;
                        }
                    }
                }
            });

        }
    }
});
Activity icon

Started a new Conversation Assign Same Value In The Vue Data Doesn't Change In The Dom

i want to change or reflect in the dom when i assign same value in the Vue data. I am really bad at explaining, sorry for that. please check the comment for more details.

<div id="app">
    <div>
        <span 
        contenteditable="true" 
        v-text="setting.change_setting_value === null ? setting.setting_default_value : setting.change_setting_value"
        @blur="changeSetting"
        >
    </span>
    </div>
</div>

const app = new Vue({
el: "#app",
data: {
    setting_default_value: "default value",
    change_setting_value: null
},
method: {
    changeSetting(evt) {
        if(evt.target.innerText === "") {
// dosen't change in the dom because setting_default_value never change its is the same value as before 
// now i want to know how can i change back the contenteditable span when i assign the same value
// i don't want to touch the dom 
            this.setting.setting_default_value = "default value" // not reflect in the dom what i can do to change the effect

// if i change the default value something else it will change in the dom in this case its the span element
            this.setting.setting_default_value = "change value" // reflect in the dom
        } else {
            this.setting.change_setting_value = "setting value has been change"
        }
    }
}
});
Jul
17
3 months ago
Activity icon

Started a new Conversation Conditionally Changing Vue Data Doesn't Effect In The View

i don't know why my view doesn't change when i change the data. i got all the settings in the data named "settings" and change the settings data with changeSetting event

data: {
                settings: {!! $admin_settings->toJson() !!}
            },
// there is only one setting something like below from database
settings : {
	0: {
		created_at: null
		id: 1
		setting_default_value: "10,5,1"
		setting_name: "User Registration Bonus"
		setting_value: null
		updated_at: "2020-07-18T04:56:27.000000Z"
	}

}
// when the response data is null it will view the setting_default_value
{
	created_at: null
	id: 1
	setting_default_value: "10,5,1"
	setting_name: "User Registration Bonus"
	setting_value: null
	updated_at: "2020-07-18T04:57:38.000000Z"
}

// when the response data is some value it will view the setting_value
{
	created_at: null
	id: 1
	setting_default_value: "10,5,1"
	setting_name: "User Registration Bonus"
	setting_value: "100,200,300"
	updated_at: "2020-07-18T04:57:38.000000Z"
}

// is the view i just do this
@{{  setting.setting_value == null ? setting.setting_default_value : setting.setting_value }} 

with axios i got the new data and change the settings data but it doesn't change in the view please see the full code below and the comment also

let app = new Vue ({
            el: "#app",
            data: {
                settings: {!! $admin_settings->toJson() !!}
            },
            methods: {
                changeSetting (evt)  {
                    let settingName = evt.target.getAttribute('name');
                    let settingValue = evt.target.innerText;
                    let response = axios({
                        method: 'patch',
                        url: "{{ route('admin.setting.update') }}",
                        data: {
                            settingName,
                            settingValue
                        }
                    }).then((response) => {
			// just change the settings value
			// because there is only one settings i just use this.settings[0] to access the first settings
                        this.settings[0].setting_value = response.data.setting_value
                        this.settings[0].setting_default_value = response.data.setting_default_value
                    });
                }
            }
        });
<tr v-if="settings.length > 0" v-for="setting in settings">
	<th>@{{setting.setting_name}}</th>
	<td class="vertical-align-middle">
		{{-- setting value doesn't change when i change it with changeSetting event --}}
		<span contenteditable="true" class="mr-5 admin-change-setting" :name="setting.setting_name" @blur="changeSetting">
			@{{  setting.setting_value == null ? setting.setting_default_value : setting.setting_value }} 
		</span>
		<i class="fa fa-pencil pull-right"></i>
	</td>
</tr>
Jul
06
3 months ago
Activity icon

Awarded Best Reply on JavaScript - Reading JSON From Text File

axios.get('google.com/complete/search?client=firefox&q=laravel')
.then(function (response) {
	console.log(response.data); // it will give you the javascript Array or Object if it is a JSON file
        console.log(JSON.stringify(response.data)); // if you want it as string you can just do this
  });
Jul
05
3 months ago
Activity icon

Replied to Eager Loading With Single Row

@snapey @tinfoilman i findout that i dont need to eagar load user. i can do what you say. but knowledge purpose how can i merge verification and user for return api resource and also hidden some user column that i can do with the with($query_method). when i eager load. also i dont want to hidden the column from model.

Activity icon

Replied to Strange Relationship - One To Four ?

// you can try this. i don't know it will work or not
// if you get the task1, task2, task3 data then it will work
public function normalTasks() {
    $a = collect($this->task1); 
    $b = collect($this->task2);
    $c = collect($this->task3);

    return $a;
        ->merge($b)
        ->merge($c);
}
Activity icon

Started a new Conversation Eager Loading With Single Row

i want a single verification record eager loading with user. please see the code comment for better undersanding

class Verification{
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
class User{
    public function user()
    {
        return $this->hasOne(Verification::class);
    }
}
// in /verification/index ----  works perfectly all the verification with the user

return UserVerification::with('user')->get(); 
// in /verification/show/{verification_id} ---- not working 
// it bring all the verification record with user not single record
// it actually brings the same record I get in /verification/index

$user_verification = UserVerification::find(verification_id);
return user_verification->with('user')->get(); 
Activity icon

Replied to JavaScript - Reading JSON From Text File

axios.get('google.com/complete/search?client=firefox&q=laravel')
.then(function (response) {
	console.log(response.data); // it will give you the javascript Array or Object if it is a JSON file
        console.log(JSON.stringify(response.data)); // if you want it as string you can just do this
  });
Jul
02
3 months ago
Activity icon

Replied to Redirect Unauthenticated User According To Guard

thanks again. you are awesome

Activity icon

Started a new Conversation Redirect Unauthenticated User According To Guard

on my website, I have multilevel authentication. for that, I set up a guard called "admin". normal user has its own dashboard with the middleware 'auth' and admin user has its own dashboard with middleware "auth:admin". whenever an unauthenticated user tries to access both dashboard it always redirects to user-login page because of the "Authenticate" middleware. now I want to know how can I redirect the unauthenticated user to user login page and unauthenticated admin-user to admin login page.

Route::get('/user/dashboard', '[email protected]')->middleware('auth');
Route::get('/admin/dashboard', '[email protected]')->middleware('auth:admin');
class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            return route('login'); // i can change to admin login then it will always be admin login page for both normal user and admin user also
        }
    }
}
Jun
24
4 months ago
Activity icon

Replied to With() Query Method Return Null

its work thank you so much

Activity icon

Started a new Conversation With() Query Method Return Null

I have a post that post belongs to a user. now I want to get a post with the associate user. but don't want to get all the user column. so in the query->select('*') it will get me all the field. but if I pass any column name in the query->select('user_column_name') of the user it always return null;

$posts = Post::find(1);
$posts()->with(['user' => function ($query) {
                $query->select('*'); // it work
            }])

            ->orderBy('created_at', 'DESC')
            ->take(1)
            ->skip(0)
            ->first();
$posts = Post::find(1);
$posts()->with(['user' => function ($query) {
                $query->select('user_phone', 'user_profile_pic'); // it not working, always return null
            }])

            ->orderBy('created_at', 'DESC')
            ->take(1)
            ->skip(0)
            ->first();