binggle

binggle

Member Since 2 Years Ago

Experience Points
3,850
Total
Experience

1,150 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
24
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
3,850 XP
Nov
22
2 weeks ago
Activity icon

Replied to Property [outlink] Does Not Exist On This Collection Instance.

Thanks for quick reply..

I will try . thanks

Activity icon

Started a new Conversation Property [outlink] Does Not Exist On This Collection Instance.

I have two models , Outlink ( parent ) and OutlinkList ( child )

in Controller

$outlink_list = OutlinkList::where( 'id', $outlink_list_id)
        ->with('outlink')
        ->get();


dd($outlink_list->toArray());

-> it display properly !!!

array:1 [▼
  0 => array:9 [▼
    "id" => 172
    "outlink_id" => 168
    "type" => "drama"
    "title" => "SomeGood outlink"
    "content" => ""
    "href" => "lnk"
    "created_at" => "2019-11-22 11:01:59"
    "updated_at" => "2019-11-22 11:01:59"
    "outlink" => array:9 [▼
      "id" => 168
      "is_notice" => 0
      "type" => "drama"
      "title" => "Title"
      "thumb_small_path" => "/upload/1.jpg"
      "content" => null
      "href" => ""
      "created_at" => "2019-11-22 11:01:57"
      "updated_at" => "2019-11-22 11:01:57"
    ]
  ]
]

We really see that there is 'outlink' property with data.

But If I try this , it goes error

dd($outlink_list->outlink);
Exception
Property [outlink] does not exist on this collection instance.

check my models

in Outlink.php (parent)

use App\Models\OutlinkList;
class Outlink extends Model
{
    function outlink_list(){
        return $this->belongsTo( OutlinkList::class );
    }
}

in OutlinkList.php (child)

use App\Models\Outlink;
class OutlinkList extends Model
{
  function outlink(){
    return $this->belongsTo( Outlink::class);
  }
}

What is the wrong with my code ?

I really can not understand what the problem is .

Nov
18
3 weeks ago
Activity icon

Replied to Vscode Live Server Laravel Setting.

Sorry but I installed extension already.

I followed the direction for 'Servers and Frameworks' ..

but I just can see the index.php . the ""Live Server" doest not run php file.

It shows just file and folder list on root folder.

More tips ?

Activity icon

Started a new Conversation Vscode Live Server Laravel Setting.

Hi . I need help .

I want to use 'live server' extension with laravel project in vscode .

I need how to setup 'live server' extension for laravel.

Can somebody give me some tips?

Activity icon

Replied to AddEagerConstraints Error With Relationship.

Thanks..

It is perfect standard answer. !!

Activity icon

Started a new Conversation AddEagerConstraints Error With Relationship.

I have two models. Webtoon and Episode .

1 Webtoon has many Episodes.

in model Webtoon


use App\Models\Episode;
use Illuminate\Database\Eloquent\Model;

class Webtoon extends Model
{

  function episodes(){
    return $this->hasMany( Episode::class );
  }

  public function lastEpisode()
  {
      return $this->hasMany(Episode::class)->orderBy('published_at', 'desc')->first();
  }

}

in Episode Model


namespace App\Models;

use App\Models\Webtoon;
use Illuminate\Database\Eloquent\Model;

class Episode extends Model
{

  function webtoon(){
    return $this->belongsTo( Webtoon::class);
  }
}

in Controller


$lists = Webtoon::with('lastEpisode')
                ->orderBy('created_at', 'desc')
                ->paginate( $perPage);
dd($lists->toArray());

it goes error following


BadMethodCallException
Call to undefined method App\Models\Episode::addEagerConstraints()

What is my mistake ?

Nov
08
1 month ago
Activity icon

Replied to Which PHP Framework Is More Suitable For An Enterprise Project?

So Goo to read your experiences..

Thanks.

Nov
04
1 month ago
Activity icon

Replied to I Want To Add Another Packages In My Custom Package

Oh... Thank you..

It is working now.

Even though I can not understand the whole picture, I feel how to solve ( adding another package into my custom package ) it .

Thanks.

Nov
03
1 month ago
Activity icon

Started a new Conversation I Want To Add Another Packages In My Custom Package

I am building my own package.

I moved User.php to my package folder

packages/myhouse/myfamily/src/User.php

** AND I want to install 'spatie/laravel-permission' package inside my OWN package. I am not sure if I am ging right. **

So I added some requires in my package.json ( packages/myhouse/myfamily/src/composer.json)

{
    "name": "myhouse/myfamily",
    "authors": [
        {
            "name": "myhouse",
            "email": ""
        }
    ],
    "require": {
      "php": "^7.2",
      "spatie/laravel-permission": "^3.2.*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

and I did

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"

it goest error .

In ProviderRepository.php line 208:

  Class 'Spatie\Permission\PermissionServiceProvider' not found

How can I add another package in my package successfully ?

Oct
29
1 month ago
Activity icon

Replied to String Field For Primary Key Goes Data Error

Yes .. You are right..

Great..

I got learned one more thing today..

Thanks.

Activity icon

Started a new Conversation String Field For Primary Key Goes Data Error

I guess it is too much simple but goes query result error .

I made Country table , models. I just want it query only .

The only point not usual is that I did not use 'id' field for primary field.

I used 'cc' field for primary .

That's it. but it goes response data error .

in migration file

Schema::create('countries', function (Blueprint $table) {
  $table->string('cc')->index()->unique();
  $table->string('name_eng');
  $table->primary('cc');
});

in Controller

function run() {
  $countries = Country::OrderBy('cc', 'asc')->take(3)->get();
  $data['countries'] = $countries;
  return response()->json( $data, 200);
}

in Country Model

class Country extends Model
{
    protected $table='countries';
    protected $primaryKey = 'cc';
    public $timestamps = false;
  protected $fillable = ['cc', 'name_eng'];
} 

in result

{
  "countries": [
    {
      "cc": 0, --> it should be 'ad' 
      "name_eng": "Andorra",
    },
    {
      "cc": 0, --> it should be 'ae' 
      "name_eng": "United Arab Emirates",
    },
    {
      "cc": 0, --> it should be 'af' 
      "name_eng": "Afghanistan",
    }
  ]
}

in backup sql

INSERT INTO `countries` (`cc`, `name_eng`)
VALUES
    ('ad', 'Andorra'),
    ('ae', 'United Arab Emirates'),
    ('af', 'Afghanistan');

Why Do I get lost 'cc' field values ?

I dont understand where the wrong comes from.

somebody can help me ?

Oct
27
1 month ago
Activity icon

Started a new Conversation How To Send Parameters To MapAction ?

in store/auth.js

actions: {
    fetchLogin({commit}, objUser ) {
        const url = EndPoints.find( ep => ep.name ==='login').path ;
        this.axios.get( url , objUser )
        .then(function (response) {
            console.log( response )
        })
        .catch(function (error) {
            console.log( error )
        });
    }
  }

How can I call fetchLogin with payload in Login.vue ?

methods: {
    ...mapActions({
      login: 'auth/fetchLogin',
    }),
}

I guess this is not enough .

Oct
26
1 month ago
Activity icon

Awarded Best Reply on V-cloak Compile Error

it is solved..

it should be

Activity icon

Replied to V-cloak Compile Error

it is solved..

it should be

Activity icon

Replied to V-cloak Compile Error

Additionally my package.json is like this.

"dependencies": { "axios": "^0.19", "bootstrap": "^4.3.1", "cross-env": "^5.1", "view-design": "^4.0.2", "lodash": "^4.17.13", "popper.js": "^1.12", "tailwindcss": "^1.1.2", "vue": "^2.6.10", "vue-router": "^3.1.2", "js-cookie": "^2.2.1", "moment": "^2.24.0", "vue2-editor": "^2.10.0", "vuelidate": "^0.7.4", "vuex": "^3.1.1", "css-loader": "^3.2.0", "resolve-url-loader": "^2.3.1", "sass-loader": "7.*", "style-loader": "^1.0.0", "node-sass": "^4.12.0", "sass": "^1.20.1" }, "devDependencies": { "laravel-mix": "^4.0.7", "popper.js": "^1.12", "postcss-loader": "^3.0.0", "vue-loader": "^15.7.1", "vue-loading-overlay": "^3.2.0", "vue-template-compiler": "^2.6.10", "webpack-livereload-plugin": "^2.2.0" }

Can somebody help me ?

Activity icon

Started a new Conversation V-cloak Compile Error

Hello.

I tried to use vuejs 2.6.10 with laravel 6.4

in App.vue

<div id="app" v-cloak>
;;
;

<style>

[v-cloak] > * { display:none }
[v-cloak]::before { content: "loading…" }

</style>

But when I run 'npm run dev' , it shows the followings.

ERROR  Failed to compile with 1 errors                                                                                

 error  in ./resources/js/App.vue?vue&type=style&index=0&lang=postcss&

Module parse failed: Unexpected token (115:12)
File was processed with these loaders:
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| } */
|
> [v-cloak] > * { display:none }
| [v-cloak]::before { content: "loading…" }
|


How can I fix this error ?

Oct
24
1 month ago
Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

Thanks for reply..

I guess it is join .. and can not be solved with eloquent relationship way only.

Maybe I must keep basics of query in mind first.

Thanks .

Oct
23
1 month ago
Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

Thanks for your concern. I Will try more .

Thanks.

Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

haha.. sure.. It is fixed and tried . no success.

Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

Sorry. it fail same ..

$nation = Nation::where('id', $nation_id)
            ->with(['ministers.officers' => function($query) {
                $query->withCount('officers', function($query) {
                        $query->where('state', 'active'); 
                })
            }])
         ->get();


mb_strpos() expects parameter 1 to be string, object given

it happens around this.


                $query->withCount('officers', function($query) {
                        $query->where('state', 'active'); 
                })

Actually I dont get how to debug this..

I check this too.. but not helping.

https://stackoverflow.com/questions/39633691/laravel-5-3-withcount-nested-relation

Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

Hi .. thanks for reply .. but it fails

$nation = Nation::where('id', $nation_id)
            ->with('ministers.officers', function($query) {
                $query->withCount('officers', function($query) {
                        $query->where('officers.state', 'active'); 
                })
            })
         ->get();



mb_strpos() expects parameter 1 to be string, object given

Activity icon

Replied to ActiveCount Of Sub Relationship Of Sub Relationship..

$nation = Nation::where('id', $nation_id)->with('ministers.officersActiveCount')->get();

yes. I tried it already.. it failed.

"Call to a member function addEagerConstraints() on integer",
Activity icon

Started a new Conversation ActiveCount Of Sub Relationship Of Sub Relationship..

I am building system with 3 models

  1. Nation has many Minister ;
  2. Each Minister has many Officer

I have 3 models ( Nation, Minister , Officer )

Model : Nation

function ministers(){
    return $this->hasMany( Minister::class );
}

Model : Minister

function officers(){
    return $this->hasMany( Officer::class );
}

 
function officersActiveCount(){
    return $this->hasMany( Officer::class)->where('state', 'active' )->count();
}

The following is workng ok . It gets all officers with corresponding ministers .

$nation = Nation::where('id', $nation_id)->with('ministers.officers')->get();

But I want to get 'ministers' and 'officersActiveCount' NOT 'officers'

How can I get the officersActiveCount with each nations ?

Oct
12
1 month ago
Activity icon

Replied to How To Access To Laravel User Model From My Custom Package ?

Thanks for info.

I will check and review again and again .

It is not easy to understand whole picture of your morph something at a glance .

Anyway Thanks .

Activity icon

Replied to How To Access To Laravel User Model From My Custom Package ?

It was my mis-clicking.

Still I don't get it ..

Could you explain more with code ?

Thanks.

Activity icon

Replied to How To Access To Laravel User Model From My Custom Package ?

Sorry sir.

But I dont get it .

Could you explain in somehow detail?

Activity icon

Started a new Conversation How To Access To Laravel User Model From My Custom Package ?

Hi . I did not start to make my package . But I wonder how to access laravel user mode from my custom laravel package ..

Is there any guid for this ?

Sep
17
2 months ago
Activity icon

Started a new Conversation Want Get Data Or Method In Relationship .

in Post Model

function user()
{
    return $this->belongsTo( \App\User::class);
}

in User Model

function posts()
{
    return $this->hasMany( \App\Post::class);
}


function somedata() 
{
    return  date('i') * 1000  + date('s'); 
}

in Controller

$posts = Post::query()
        ->where('id', 10)
        ->with('user')
        ->get();

but it does not get 'somedata' in user model .

How can I drag this data with posts ?

Sep
16
2 months ago
Activity icon

Replied to Is Mass Assignment Dangerous ?

Thanks for comments.

So there is no best way to protect sqli without Validation / Model guard ..

I wish there is more easy way for security.

Anyway Thanks.

Thanks all guys.

Activity icon

Started a new Conversation Is Mass Assignment Dangerous ?

Simple Questions.

$user = new User(Input::all());

Is this code dangerous for sql injection ?

Sep
15
2 months ago
Activity icon

Replied to Find Out All Logged In Users

I did this in another way which uses Redis for performance.

Someone can refer this : https://laracasts.com/discuss/channels/laravel/how-to-retrieve-all-alive-sessions-including-another-uses-session

Activity icon

Replied to How To Retrieve All Alive Sessions Including Another Uses Session?

Thanks for comments.

I got solved my problem .

I leave my code here for someone who are looking for same prob.

in .env


CACHE_DRIVER=redis
SESSION_DRIVER=redis

.. in SessionCheck middleware

namespace App\Http\Middleware;


use Carbon\Carbon;

use Closure;

use Illuminate\Support\Facades\Redis;


class SessionCheck

{

    private $key="user_live_time"; 

    public function handle($request, Closure $next)

    {
        $response = $next($request);

        $user = auth()->user();
        $user_id = $user->id;
        $uid= $user->uid;
        if( $uid =='admin') {
            return $response;
        }

        $values = Redis::command('HSET', [ $this->key, $uid , Carbon::now()->addMinute()]);
        return $response;
    }

} 

.. in Route.php

Route::group(['middleware'=>['auth', 'SessionCheck' ] ] , function(){

   Route::....


});

.. in Controller ..

function get_live_users(){

              $key="user_live_time";
              $current_users = [];
              $today_users = [];

              $sessions = Redis::command('HGETALL', [ $key]);

              $now = Carbon::now();
              foreach( $sessions as $uid => $session ){
                  $diff = $now->diffInSeconds( $session) ;
                  if( $diff <=60){
                      $current_users[]= $uid ;
                  } elseif( $diff < 60 * 60 * 24 ) {
                      $today_users[] = $uid ;
                  } else{
                      Redis::command('HDEL', [ $key, $uid]);
                  }
              }

              $today_users =  array_merge ( $current_users, $today_users);
              $current_users = $current_users ; 

              $users = User::whereIn('uid', $current_users)->paginate($perPage);
              return response()->json($users);
}


Sep
10
2 months ago
Activity icon

Replied to How To Use 'with()' In Laravel DB Query Builder ?

You the really great . Thanks

Activity icon

Started a new Conversation How To Retrieve All Alive Sessions Including Another Uses Session?

HI . I want all users sessions data as admin of website.

I am using redis for session driver .

How can I get this ?

Sep
05
3 months ago
Activity icon

Replied to How To Use 'with()' In Laravel DB Query Builder ?

Because 1st and 2nd are not from users .

I really need those kind relationships model .

I wish I can find the way.

Activity icon

Started a new Conversation How To Use 'with()' In Laravel DB Query Builder ?

In this case I gave up to use ORM Eloquent .

SO I decided to use DB Query builder only.

But I want to drag 'user' model with my 'results' model .

How can I get success ?

    $bettings = DB::table('results')
            ->select('1st', '2nd', DB::raw('SUM(time_laps) as time_laps'))
            ->where('event_id', $event_id)
            ->join('type', function( $join) use( $type) {
                $join->on('results.type_id', '=', 'type.id')
                        ->where('types.key' , '=', $type) ;
            })
            ->groupBy('1st', '2nd')
            ->with('user')
            ->get();


            ->with('user')

I guess I can not use with() in Query Builder.

Actually I wish I can build ORM Eloquent query than DB Query Builder .

If it's not possible I want to drag user model with results model .

Can someone help me ?

Activity icon

Replied to 'whereHas' Just Return The Last Record..

Sorry guys..

it was mistake..

Don't mind this question.

Activity icon

Started a new Conversation 'whereHas' Just Return The Last Record..

I want to retrive all Events records with belongsTo relationship ( Type )

But it gives me just one last Event record .

Can someone help me ?

in Controller .

$events = Event::where('weekday', $weekday)
            ->whereHas('type', function(  $q) use($type) {
                 $q->where('key',  $type);
            })->get();

Event.php

class Event extends Model {


    function type(){
        return $this->belongsTo('App\Type');   
    }
    

}

Type.php

class BetType extends Model {
        
    function events(){
        return $this->hasMany( App\Event::class);
    }

}

TIA

Aug
18
3 months ago
Activity icon

Replied to How To Avoid Checking 'composer.json' When Run Command ?

Sorry for late response.

I tested it .

I remove 'composer.json' file and runned customized command with php artisan .

It display errors.

Aug
16
3 months ago
Activity icon

Replied to [Vue Warn]: Error In V-on Handler: "TypeError: Getlist_charge Is Not A Function" ??

OMG..

you save my friday and weekend..

Thanks a lot @dunsti

Activity icon

Replied to [Vue Warn]: Error In V-on Handler: "TypeError: Getlist_charge Is Not A Function" ??

I guess it is cause of

@click="getlist_charge('{{ $key }}')"

I don't get why ..

Help me !!

Activity icon

Started a new Conversation [Vue Warn]: Error In V-on Handler: "TypeError: Getlist_charge Is Not A Function" ??

hi . I just use blade and vuejs script in same php file.

it vomit errors following.

[Vue warn]: Property or method "getlist_charge" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property

[Vue warn]: Error in v-on handler: "TypeError: getlist_charge is not a function"

vue.js:1897 TypeError: getlist_charge is not a function at click (eval at createFunction

Can someone check my codes ?


@php 

$statuss = [
    '1' =>'all',
    '2'=>'waiting',
    '3'=>'done'
];
@endphp 

<div id="main">
     <div class="card-body">
    CHARGES @{{  brand }}

        @foreach( $statuss as $key=>$status )
            <button class="btn btn-sm btn-sm" :class="status_charge=='{{ $key }}' ? 'btn-info' : 'btn-success'" @click="getlist_charge('{{ $key }}')">
            {{  $status }}
            </button>
        @endforeach 
    </div>
</div>


<script>


const main = new Vue({
  el: '#main',
  data() {
    return {
        brand: '1234', 
    }
  },
  method: {
    getlist_charge : function( div) {
        alert( div );
        
    }

  }
})
 

</script> 




brand display '1234' correct ;

TIA

Aug
14
3 months ago
Activity icon

Started a new Conversation How To Avoid Checking 'composer.json' When Run Command ?

Hi ..

I have to distribute my laravel source code . it includes some of Console Commands which will be runned by Cronjob.

When I run php artisan spme:cmd , it checks 'composer,json' .

But I dont want my client look into my source code in detail nor upgrade without my watching.

how can I avoid checking 'composer.json' ?

Activity icon

Started a new Conversation Momentjs Format Not Works Properly In Vuejs

hi .

I got json Data from Laravel server

when I display without moment js, it looks fine with correct data .

But with momentjs format it display all wrong data .

check parts of my code.

The followings are working correct as written

@{{ event['event_time'] }}

it displays

2019-08-14 12:00:00 2019-08-14 13:10:00 2019-08-14 14:20:00 2019-08-14 15:30:00 ; ;

But with moment

@{{ moment( event['event_time'], "YYYY-MM-DD HH:mm:ss" ).format( "MM-DD HH:mm" ) }}

08-14 14:03 08-14 14:03 08-14 14:03 08-14 14:03 08-14 14:03 ; ;

it display same and incorrect data

What is wrong with my code ?

Jul
30
4 months ago
Activity icon

Replied to How To Get Model Id In Eloquent Model ?

You saved me !!

Thanks

Activity icon

Started a new Conversation How To Get Model Id In Eloquent Model ?

hi

I want to get sum of coins table with where in User Model.

class User extends Model
{

  public function today_charge()
  {
    $self = self::class;

    $sum = DB::table('coins')->where('user_id', $self->id)
        ->where('div', 'charge')->where('status', 'confirmed')->sum('amount');
    return $sum;

  }

}

How can I access self->id ?

Jun
24
5 months ago
Activity icon

Started a new Conversation Vuejs : Cannot Access Store ( Vuex ) In Event.$on

Hi .. I am newbie on Vuejs / Vuex

I am using Laravel 5.8 and Vuejs 2.6.10 , vuex 3.1.1 ..

I can not understand why I can not access $store in event bus .

  • event-bus.js

import Vue from 'vue'; const EventBus = new Vue(); export default EventBus;

  • Toolbar.vue

exit_to_app import { mapGetters } from 'vuex'

import EventBus from '~/event-bus';

export default { components: { Dropdown, LeftDrawer }, created () { this.$bus.$on('logged', () => { // this.isLogged = this.checkIfIsLogged() this.isLoggedIn = this.$store.getters.isLoggedIn; }) }, mounted () { EventBus.$on('LOGIN', function (payLoad) { console.log('payLoad'); console.log(this.$store); --> can not access this.isLoggedIn = this.$store.getters.isLoggedIn; --> not working this.isLoggedIn = this.checkIfIsLogged() --> not working .. }); }, computed : { ...mapGetters([ 'isLoggedIn', ]) }, methods: { checkIfIsLogged () { let token = this.$localStorage.get('access_token') if (token) { return true } else { return false } }, }

}

-- Login.vue

import EventBus from '~/event-bus';

export default { data(){ return { email : "[email protected]", password : "" } }, methods: {

  login: function () {
    let email = this.email
    let password = this.password
    this.$store.dispatch('login', { email, password })
   .then( () => {
     this.event_login( );
    this.$bus.$emit('LOGIN', 'User logged');
     this.$router.push('/')
   })
   .catch(err => console.log(err))
  }
}

}

I want to show 'Logout' text in Toolbar after Login success .

But I guess I can not access store.

See the code again .

mounted () { EventBus.$on('LOGIN', function (payLoad) { console.log('payLoad'); console.log(this.$store); --> can not access this.isLoggedIn = this.$store.getters.isLoggedIn; --> not working this.isLoggedIn = this.checkIfIsLogged() --> not working .. }); },

How can I fix this trouble ?

Is there someone who can help me ?