murilo

murilo

Member Since 3 Years Ago

Ribeirão Preto

Experience Points
31,460
Total
Experience

3,540 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
253
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 7
31,460 XP
Feb
07
2 weeks ago
Activity icon

Replied to Laravel Session Save Is Not Working With Request

it will not work . I dont know why . I think that is becose it has many requests , in a short time , and the session does not work . maybe is that

Activity icon

Replied to Laravel Session Save Is Not Working With Request

If I do like this ( with setTimeout ) , it will works the session . otherwise , It does not works .

loadPage() {

    
                Promise.all([

                // RESET ALL FILTERS
                    this.$store.dispatch('reset_all_filters') ,

 
                    // EXTRA OPTIONS
                    this.$store.dispatch('load_extra_options') ,

                    // LOAD OPTIONS
                    this.$store.dispatch('load_form_options')

                ]).then((res) => {
              

         let wait = setTimeout(() => {
                            clearTimeout(wait);
                            // THEN I SAVE THE SEARCH SESSION
                          this.$store.dispatch('save_session_search') ,
                        }, 6000)
         });

 });

Activity icon

Replied to Laravel Session Save Is Not Working With Request

Hello @fylzero AND @sinnbeck , after many tries and testing , I start to understand what is happening .

well , In VUE if I load the page and just make this request -

this.$store.dispatch('save_session_search') ,

IT will works . but the problem is that I have other requests before this one to load the page , it is like this

 loadPage() {

    
                Promise.all([

                // RESET ALL FILTERS
                    this.$store.dispatch('reset_all_filters') ,

 
                    // EXTRA OPTIONS
                    this.$store.dispatch('load_extra_options') ,

                    // LOAD OPTIONS
                    this.$store.dispatch('load_form_options')

                ]).then((res) => {
                // THEN I SAVE THE SEARCH SESSION
                this.$store.dispatch('save_session_search') ,
         });

 });




LIKE THIS THE SESSION IS NOT WORKING . but it access the laravel page , I know that access there becose I tested in my console . but it not save the session .

My question is , does laravel limit the session , when make many requests ? I have never seen this .

Feb
06
2 weeks ago
Activity icon

Replied to Laravel Session Save Is Not Working With Request

I added this code in the Kernel.php -

  protected $middleware = [
...
        \Illuminate\Session\Middleware\StartSession::class,
    ];


ALSO

'api' => [
    \Illuminate\Session\Middleware\StartSession::class, 
            'throttle:3000,1',
            'bindings',
        ] ,


BUT IT DIDNT WORK , it works if I access the url BUT does not work if I send a request from VUE

Activity icon

Started a new Conversation Laravel Session Save Is Not Working With Request

Hello , I am trying to save a session in Laravel with my Request . but it is not working .

this is the session -

  public function save_session(Request $request)
    {
          $request->session()->put('my_session', "it saved one value");
          $request->session()->save();
           return ['successs' => true ];
}

if I access the route of the session like this -

mywebsite.com/save_session

It will works good and save the session . BUT , if I send a request from VUE , like this -

            axios.get(/save_session)
                .then(response => {
                     console.log(response.data); // {successs: true}

                })

It will get my response , BUT WILL NOT SAVE THE SESSION . I dont know what is happen , If I access the route . It works the session . BUT if I send a request from VUE . IT not works .

Jan
27
4 weeks ago
Activity icon

Replied to SVG Fill , Change SVG Color With VUE

Thanks @ismaile , It worked

Activity icon

Replied to SVG Fill , Change SVG Color With VUE

@ismaile , there is any way that I can change the color of the svg withou change the image.svg with the editor ?

Activity icon

Started a new Conversation SVG Fill , Change SVG Color With VUE

Hello , I have been tryng to change a color of a SVG , with fill , but it is not working . I am doing like this -

 <img :src="'/assets/images/image.svg " :fill="'#FFF'" class="imgicon">

I tryed ad welll to change in the css -

 div.imgicon {
        fill: green !important;
    }

But it didnt changed ,

Jan
23
1 month ago
Activity icon

Started a new Conversation Check If Has Value In An Object Array

Hello , I wold like to know if has a better ways to check if has a value inside an Object that is inside an Array , without make foreach , like this -

    this.verifyHasTitle('Post One'); // TRUE
         this.verifyHasTitle('Post Four'); // FALSE
`

the data -

  data(){
            return {
                posts:[{ id: 1 , title:Post One } ,
                { id: 1 , title:Post Two } ,    
                { id: 1 , title:Post Three } ,  ]
            }
        } ,

the Method -

verifyHasTitle(title_selected){

     for(let prop in this.posts)
        {
            if(this.posts[prop ].title == title_selected){
                return  true;
            }

        }
    return false;

}

Jan
03
1 month ago
Activity icon

Replied to Session Is Not Working Inside Rule In Laravel 6

hello @Nakov , I didnt yell . I typed uppercase just to stay more beutfull to read the code . Thanks for the help . I cant Access the session inside the form Request -

use Session;
class SendMessageRequest extends FormRequest
{

     public function authorize()
    {

        return true;
    }

 public function rules()
    {
        dd(Session::get('captcha'))
        return [
          // just a example , the session captcha will be not acced from Form Request , is Allways Null 
        ];

    }
}

It will be not possible

Activity icon

Started a new Conversation To Many Requests With Passport

Hello , O have been working with Passport Password Grant_type , and I have an error of Many Requests , I wold like to increase the number of requests of passwords try .

It is giving this error -

GuzzleHttp\Exception\ClientException: Client error: `POST my-website/oauth/token` resulted in a `429 Too Many Requests` response:

This is my code -

$http = new Guzzle;


           $response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->email ,
                    'password' => $request->password ,
                    'provider' => $type_access ,
                    'scope'    => '*'
                ]
            ]);


           return   $response->getBody();

I tried to increase the number of requests in the Kernel.php file -

'api' => [
            'throttle:3000,1',
            'bindings',
        ] ,

But it didnt work , how could I increase the number of password try ? thanks

Jan
02
1 month ago
Activity icon

Started a new Conversation Get Token AND User Detail ( All Together ) With Passport

Hello , I have been using Passport Authentication with VUE JS .

FIRST I GET THE TOKEN -

$http = new Guzzle;

        try {
           $response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->email ,
                    'password' => $request->password ,
                    'provider' => $type_access ,
                    'scope'    => '*'
                ]
            ]);


           return    $response->getBody();

        }

NOW THAT I HAVE THE TOKEN , I CAN GET THE USER INFORMATION ( I HAVE TO SEND THE TOKEN IN THE HEADER ), LIKE THIS -

$user = auth('api')->user();
        return response()->json([
            'email'     => $user->email,
            'name'      => $user->name,
            'last_name' => $user->last_name
        ]);


Does have some how . when I get the token , I get as well the user information ? something like this will be not possible -

    $http = new Guzzle;

        try {
           $response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->email ,
                    'password' => $request->password ,
                    'provider' => $type_access ,
                    'scope'    => '*'
                ]
            ]);


              
    $user = auth('api')->user();
    
        return response()->json([
            'email'     => $user->email,
            'name'      => $user->name,
            'last_name' => $user->last_name ,
            'token'         => $response->getBody();
        ]);

        }

Activity icon

Started a new Conversation Passport Authentication - Get User Details When Login

Hello , I have been working with VUE + Laravel Authenticaton .

I have this function that verify the credentials of the users AND return the access tokens to VUE -

public function login(Request $request)
    {
        $http = new \GuzzleHttp\Client;
        try {
            $response = $http->post(config('/oauth/token'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->username,
                    'password' => $request->password,
                ]
            ]);
            return $response->getBody();
        } catch (\GuzzleHttp\Exception\BadResponseException $e) {
            if ($e->getCode() === 400) {
                return response()->json('Invalid Request. Please enter a username or a password.', $e->getCode());
            } else if ($e->getCode() === 401) {
                return response()->json('Your credentials are incorrect. Please try again', $e->getCode());
            }
            return response()->json('Something went wrong on the server.', $e->getCode());
        }
    }

The problem is that I want to return as well , the user detail . ( Name and E-mail ) . how could I get those informations ?

Thanks

Dec
31
1 month ago
Activity icon

Started a new Conversation Laravel Passport , Multi Authentication , Different Tables

Hello , I have been working with Vue + Laravel . I have been using passport to authenticate . I need to make a new authentication table in a new model . for customers . It will be like this my model -

    'api' => [
            'driver' => 'passport',
            'provider' => 'user_admin',
            'hash' => false,
        ],

        'customer' => [
            'driver' => 'passport',
            'provider' => 'user_customer',
            'hash' => false,
        ],

I get the token using those credentials - this route -

http://my-website/oauth/token

with the information of the USER_ADMIN table , ( API CONFIG )-

grant_type     -  password
client_id         -  2
client_secret - 2WJsGTOIrf72WHHgshgdJ7mx87343j5UVcX5prEY3Az
username     - [email protected]
password      -  123456

what I am trying to do is , to access with the CUSTOMER table , ( customer CONFIG ) . how can I make passport to access this config for customers logins ? -

 'customer' => [
            'driver' => 'passport',
            'provider' => 'user_customer',
            'hash' => false,
        ],

Thanks

Dec
30
1 month ago
Activity icon

Replied to Session Is Not Working Inside Rule In Laravel 6

hello @Nakov , I am adding like this

session()->put('captcha', 'my-captcha-name');

IT IS WORKING , BECOSE I CAN GET THIS SESSION FROM MY CONTROLLER LIKE THIS -


class SiteController extends Controller
{
     public function index()
    {
        dd(session()->get('captcha'));
      }
}

BUT IT IS NOT WORKING INSIDE THE RULE , IN LARAVEL 5.8 IT USED TO WORK , BUT NOW IT IS NOT WORKING ANY MORE .

Activity icon

Started a new Conversation Session Is Not Working Inside Rule In Laravel 6

I have in my Form Request , a Rule that Verify Captcha -

use App\Rules\VerifyCaptcha;

 public function rules()
    {

        return [
            'captcha'                   => ['required' , new VerifyCaptcha() ]
        ];
    }

verify VerifyCaptcha.php Rule File -

 public function passes($attribute, $value)
    {
       
        if($value == Session::get('captcha')){
            return true;
        }

        return false;
    }

Before , in Laravel 5.8 , this code used to works , but in Laravel 6 . SESSION IS NOT WORKING INSIDE THE RULE , I tried inside the form request as well . It does not work .

I tried ass well -

 public function passes($attribute, $value)
    {
       
        if($value == session()->get('captcha')){
            return true;
        }

        return false;
    }

If I print this in my controller , it works -

class SiteController extends Controller
{
    public function index()
    {
        dd(session()->get('captcha'));
    }
}

BUT INSIDE MY RULE IT IS NOT WORKING ANY MORE . IN LARAVEL 5.8 IT USED TO WORK .

Dec
10
2 months ago
Activity icon

Started a new Conversation Vue Router Link With A Reload Component Option

I have 2 pages that uses the same component ( News And Articles ) , and I have a menu that has links that goes to those pages -

The Menu -

<ul>
       <li><router-link :to="{ name: 'News'}" >News</router-link></li>  
        <li><router-link :to="{ name: 'Articles'}" >Articles</router-link></li>
</ul>

The Router -

 {
        path: '/news*',
        name: "News",
        component: Posts ,
        meta: {
            type:'news'
        }
    } ,
 {
        path: '/articles*',
        name: "Articles",
        component: Posts ,
        meta: {
            type:'articles'
        }
    } ,

The Posts Page Component -

created(){
    this.loadPage(this.$route.meta.type);
}

The problem is -

  • if I am in News Page , and click to go to Articles Page . it does not goes to Article Page .
  • if I am in Articles Page , and click to go to News Page . it does not goes to News Page.

It happens becose VUE detect that it is the same component , and it not change the page .

How could I make VUE reload this component again , and change the page ?

Dec
09
2 months ago
Activity icon

Awarded Best Reply on Dynamic Vue Router Link

I solved like that -

  goLoadFilters( filterName , filterId ){
        let filters = {};
                filters[filterName] = 'dolor';

                this.$router.push({ path: '/posts', query: filters });
}


Activity icon

Replied to Dynamic Vue Router Link

I solved like that -

  goLoadFilters( filterName , filterId ){
        let filters = {};
                filters[filterName] = 'dolor';

                this.$router.push({ path: '/posts', query: filters });
}


Activity icon

Started a new Conversation Dynamic Vue Router Link

Hello , I want GO TO A POST PAGE WITH FILTERSS something like this dynamic -

<a href="#" @click.prevent="goPostPageWithFilter('category' , id )"  >Category One </a>


<a href="#" @click.prevent="goPostPageWithFilter('sub_category' , id )"  > Sub Category One </a>

LIKE THIS IT WORKS -

 methods: {
      goLoadFilters( filterName , filterId ){
        if(filterName  == category){
                     this.$router.push({ path: '/posts', query: { category: filterId  } });
        }

        this.$router.push({ path: '/posts', query: { sub_category: filterId  } });
            } ,
}

BUT LIKE THIS WILL NOT WORKS , IT NOT ACCEPT DYNAMIC PARAMETER LIKE THIS -

 methods: {
      goLoadFilters( filterName , filterId ){
                this.$router.push({ path: '/posts', query: { filterName : filterId  } });
            } ,
}

How could I make it dynamic , like the first option .

Nov
24
3 months ago
Activity icon

Started a new Conversation Vue Router URL If Has Suffix ?id= , Goes To Other Component

Hello , It want change the component of the VUE Router , if the URL contains - ?id=

SO I DID SOMETHING LIKE THAT -

    {
        path: '/product?id=*',
        name: "ProductDetail",
        component: ProductDetail,
        meta: {
            template: "web"
        }
    } ,


    {
        path: '/product*',
        name: "ProductsIntro",
        component: ProductsIntro,
        meta: {
            template: "web"
        }
    } ,


BUT IT DIDNT WORK .

Does have any how to do thins in VUE router ?

Nov
18
3 months ago
Activity icon

Replied to What Is A Good Size For A Vue Single App File ?

hello @hollyit , the problem is the first loading .

Activity icon

Replied to What Is A Good Size For A Vue Single App File ?

hello @fylzero ,

I am using this library - https://www.iviewui.com

It is responsible for 800 KB , of my file . Do you use Vue CLI ? Does VUE CLI has a first time loader ( that stay loading when all the code the code is loading for the first time ) ?

Activity icon

Started a new Conversation What Is A Good Size For A Vue Single App File ?

Hello , I have been working with VUE + Single Page Application . and I think that my file become very big .

my JS file has 2,000 KB . It that s very big for a file ?

When I load this website that I am building for the first time , it takes very long to load . does have any way to have a vue loader wile all the code is being loading ?

Nov
14
3 months ago
Activity icon

Started a new Conversation Laravel Vs Lumen In Single Application

Hello guys , I have been developing Single Appliication with Laravel + Vue . I start learning Lumen , and I in doubt if in my new project I start wit laravel or Lumen .

What wold be the most recommended for a single app application , Monolitic Project ( one database ) . Laravel or Lumen ? Is Lumen faster than Laravel in requests ?

Nov
08
3 months ago
Activity icon

Awarded Best Reply on I Cant Access API Route Get Via POST MAN In Laravel 6

I have solved , It was my error .

Activity icon

Replied to I Cant Access API Route Get Via POST MAN In Laravel 6

I have solved , It was my error .

Activity icon

Started a new Conversation I Cant Access API Route Get Via POST MAN In Laravel 6

Hello , I have this route -

Route::name('test')->get('test', '[email protected]');

if I add it in routes/web.php , I will be able to access my index of TestController by POST MAN . BUT if I add in routes/api.php , it will gives me 404 Error .

In Laravel 5.8 It works , but in Laravel 6 , it is not working . I dont know if I am doing something wrong . Did something changed in routes API between Laravel 5.8 to 6 ?

Thanks

Nov
07
3 months ago
Activity icon

Started a new Conversation Mesure Time Of Search In Laravel

Hello Guys I have a search in Laravel that is very big and join many tables , it bring me back a json response as result . I wold like to know if in Laravel , there is an way to know , or count the time of possessing of this search .

Thanks

Oct
10
4 months ago
Activity icon

Replied to JWT Multh Auth , With Different Models ( User Model , Customer Model )

My friends , I found the error , I forgot to add those line of code inside the Customer class -

  public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Return a key value array, containing any custom claims to be added to the JWT.
     *
     * @return array
     */
    public function getJWTCustomClaims()
    {
        return [];
    }

Thanks a lot

Activity icon

Replied to JWT Multh Auth , With Different Models ( User Model , Customer Model )

hello @walidabou , this is the errro

Class App\Customer contains 2 abstract methods and must therefore be declared abstract or implement the remaining methods (Tymon\JWTAuth\Contracts\JWTSubject::getJWTIdentifier, Tymon\JWTAuth\Contracts\JWTSubject::getJWTCustomClaims)
Activity icon

Replied to JWT Multh Auth , With Different Models ( User Model , Customer Model )

hello @smally , I think that is better as well using all in the same model . but I will have to use this in a different model for this project . becose It is a project that It already exist like that way . I am using guards , but my question is if I implement JWTSUbject class in other model will not work like that -

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Customer extends Authenticatable  implements JWTSubject
{
    protected $table      = 'customer';
}

will give error . if I use passport class instead , it will work with 2 models ?

Activity icon

Started a new Conversation JWT Multh Auth , With Different Models ( User Model , Customer Model )

Hello I use JWT Auth , and I am trying to make a multh auth with JWT with 2 Models . (USER Model AND CUSTOMER Model ) .

Like this -

    * USER ( for ADMINS  )
         *CUSTOMER ( for CUSTOMER )

in the User model I have this code , It works -

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable  implements JWTSubject
{
     protected $table      = 'users';
}

BUT in the modal CUSTOMER , I CAN NOT do that -

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Customer extends Authenticatable  implements JWTSubject
{
    protected $table      = 'customer';
}


It will give me error , I tried this as well -

use Tymon\JWTAuth\Contracts\JWTSubject;
use Illuminate\Foundation\Auth\Customer as Authenticatable;

class Customer extends Authenticatable  implements JWTSubject
{
    protected $table      = 'customer';
}

I was no success

Sep
29
4 months ago
Activity icon

Started a new Conversation Laravel Request , Dont Repeat Same Title

I have this laravel request -

  public function rules()
    {
        return [
                   'title'               => 'required|unique:posts' ,
    ]
}

That dont repeat the Title name in the POST , if I try to create a POST with the same title it will not aloud me .

BUT if I try to update that post , it will not aloud this title EXISTS . I have to make a request like that -

when update -
    1) If is the post , is the same one of that title . dont validate it .
        2) validate if try to make a title , different of that POST

does have any request like this in laravel ? or will I have to make a new custom class request ?

Thanks

Sep
18
5 months ago
Activity icon

Replied to Vuex , How Make A Betther Code

I wold like to implement a class inside the VUEX , I dont know if that is possible . or something like that in my VUEX MUDULES -

import CrudMuttation from "../cruds/mutation";
import CrudActions from "../cruds/actions";
import CrudGetters from "../cruds/getters";
import CrudGetters from "../cruds/getters";

const state = { 
    pageProperty : { title:'' , product:'' }  ,
        searchProperty: { title:'' }  
}

const mutations = {
    CrudMuttation 
}

const actions= {
    CrudMuttation 
}

const getters= {
    CrudGetters 
}


export default {
    namespaced:true ,
    state,
    mutations,
    actions,
    getters
}

can I do something like that ?

Sep
17
5 months ago
Activity icon

Started a new Conversation Vuex , How Make A Betther Code

Hello Guys , I wold like to know if has any way to re use codes , or expand a class inside VUEX . I know that in VUE we have mixins , but I dont know if that it is possible to use in VUEX . I have many VUEX CRUD modules . and in all those modules I have those actions ( they are the same )-

 set_filters: ({commit}) => {
  } ,
store: ({commit} , data ) => {
}
update: ({commit} , data ) => {
}
delete: ({commit} , data ) => {
}
pagination: ({commit} , data ) => {
}
search: ({commit} , data ) => {
}

What wold be the best practice to I dont repeat all those code in all those VUEX modules ?

Sep
16
5 months ago
Activity icon

Started a new Conversation Best Approach Using VUEX Modules In Vue Cruds And Not Repeat Codes

Hello Guys , I wold like to know if has any way to re use codes , or expand a class inside VUEX . I know that in VUE we have mixins , but I dont know if that it is possible to use in VUEX .

I have been working with VUEX , And I separated into modules . but I dont know if I have been working with the best approach becose I have been repeating to much codes inside VUEX MODULES .

I have many CRUDS , like those -

POST CRUD , POST_CATEGORY CRUD , POST_SUB_CATEGORY CRUD ....

and in VUEX I have those MODULES -

    post_module
    post_category_module
    post_sub_category_module
         .....
    

And in those those modules I have those codes that I repeat -


const actions = {
    set_filters: ({commit}) => {
        SAME CODE IN ALL CRUD MODULES
    } ,

    selectAll: ({commit}) => {
            SAME CODE IN ALL CRUD MODULES
    } ,
    
    changePagePagination: ({commit} , data ) => {
        SAME CODE IN ALL CRUD MODULES
} ,

store: ({commit} , data ) => {
SAME CODE IN ALL CRUD MODULES
}

update: ({commit} , data ) => {
SAME CODE IN ALL CRUD MODULES
}
delete: ({commit} , data ) => {
SAME CODE IN ALL CRUD MODULES
}

AND TO MUCH MORE .....



What wold be the best approach that ? wold be -

  1. instead use those modules , use just one module that will make everthing - CRUD_module for example ?
  2. could I use mixins inside VUEX ? I dont know if this is possible .
  3. there is and way to expland a class inside vuex , like POST_CATEGORY_MODULES expands CRUD_MODULES ... ?

Thanks

Sep
08
5 months ago
Activity icon

Started a new Conversation How Recuperate The User Id With JWT Token Inside Laravel ?

hello , I have been trying to recupareta the user ID with JWT class . this one - https://jwt-auth.readthedocs.io/en/develop/

I have this token -

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJod…FhIn0.zPLtF5N8lKwYZslLY7l9D-0TXCPp2X4VCPY6jsyznWw

and I send this to VUE to Laravel . in Laravel I want to know the user id of this token ( the user that is logged in ) . How can I recuperate this information in Laravel ?

Thanks

Sep
07
5 months ago
Activity icon

Replied to JWT AUTH , How Can I Recuparate The User Detales In The Controller

Hello @Sti3bas , thanks so mutch for answer . do I have to send aways the token ?

It has this function , in this class -

    public function me()
    {
        return response()->json(auth('api')->user());
    }

I thought this could bring me back the USER , but it brings me NULL .

Activity icon

Started a new Conversation JWT AUTH , How Can I Recuparate The User Detales In The Controller

Hello , I am trying to work with VUE Spa Applications + Laravel .

I am trying to recuparate the user detalhes that is Logged In , in the Controller becose when I have to add a POST , I need the ID of the USER that is creating this POST .

I am making the Auth with JWT class , like this example -

https://www.youtube.com/watch?v=Jd1RW-0lQOs&list=PLJpBh2VJhy5wPhAmjDB42pkHUnqolqxxq

it is working , it makes the authenticaton , and return the user detale ,to front ( VUE ). I have those credentias in the VUE , but I dont want to pass those informations by Javascript to the BACK .

this is my authentication -

use Auth;

if(auth()->guard('api')->attempt($credentials)){
    // SUCCESSS
}

I am tryng to recuparete the user like this -

     $user = Auth::guard('api')->user();
     dd($user) ; // null
    

or

 $user = Auth::guard('api');
 dd($user) ;

// result ->
JWTGuard {#280 ▼
  #lastAttempted: null
  #jwt: JWT {#286 ▶}
  #request: Request {#43 ▶}
  #user: null
  #provider: EloquentUserProvider {#317 ▶}
}


How could I recuparate the user ID in my controller ? is that a correct approutch ?

Aug
31
5 months ago
Activity icon

Started a new Conversation Many Promisses With VUEX

Hello ,I am tryng to think the best way to do this in VUEX .

* LOAD PROMISE_A
* AFTER PROMISSE_A IS LOADED , LOAD PROMISSE B
* AFTER PROMISSE_B IS LOADED , LOAD PROMISSE C

* AFTER SHOW THE RESULT

it is something like this in Java Script I want to do

 //   Will resolve after 400ms
   let promiseA = new Promise((resolve, reject) => {
                    let wait = setTimeout(() => {
                        clearTimeout (wait);
                        resolve("PROMISSE A RUNNED FIRST");
                    }, 400)
                })


                //   Will resolve after 200ms
                let promiseB = new Promise((resolve, reject) => {
                    let wait = setTimeout(() => {
                        clearTimeout (wait);
                        resolve("PROMISSE B RUNNED AFTER");
                    }, 200)
                })

                // shows
                 Promise.all([
                    promiseA,
                    promiseB
                ]).then((res) => console.log(res))

        // RESULT IS ->  ["PROMISSE A RUNNED FIRST", "PROMISSE B RUNNED AFTER"]


IF I TRY LIKE THIS IN VUEX , MY ACTION

const actions = {
load_page: ({commit}) => {

       Promise.all([
            commit('PROMISSE_A') ,
            commit('PROMISSE_B')
        ]).then((res) => console.log(res));


    },
}

MUTTATIONS

const mutations = {
      'PROMISSE_A'(state){
        return new Promise((resolve, reject) => {
                let wait = setTimeout(() => {
                    clearTimeout (wait);
                    resolve("PROMISSE A RUNNED FIRST");
                }, 400)
        })

    } ,

    'PROMISSE_B'(state){
        return new Promise((resolve, reject) => {
            let wait = setTimeout(() => {
                clearTimeout (wait);
                resolve("PROMISSE A RUNNED FIRST");
            }, 200)
        })

    } ,

}


IT WILL RETURN

    ['undefined' , 'undefined' ]

what wold be the best way to do that in VUEX ?

Aug
25
6 months ago
Activity icon

Started a new Conversation Change The Css Of The Page In VUE SPA Project With Vue Route

Hello , I have a question . I am woring on a VUE SPA project . and I wold like to know how colud I change the style of my page ( CSS ) with the VUE route . it is that possible ?

I have 3 style of pages in my project

* Main Web Site
*Login Area
* Admin ARea

and I have in my blade , this code that Load the components (those pages )-

<div class="whapper" id="app" >
    <main-app></main-app>
</div>

and in my vue route -

  {
        path: '/contact',
        component: Contact
    } ,
  {
        path: '/admin/home',
        component: AdminHome
    } ,

Could I make something like that in my Route ? -

  {
        path: '/contact',
        component: Contact ,
    styleCSS:web
    } ,
  {
        path: '/admin/home',
        component: AdminHome ,
styleCSS:admin
    } ,
Activity icon

Started a new Conversation Use Sweet Alert Inside VUEX

Hello , I am trying to use SWEET Alert inside the vuex store file . but it does not works , it says -

TypeError: Cannot read property '$swal' of undefined"

But if I use inside my component , it works .

I am importing like this in my app.js file -

import VueSweetalert2 from "vue-sweetalert2";
Vue.use(VueSweetalert2);
Aug
24
6 months ago
Activity icon

Started a new Conversation Two Way Data Binding Form With VUEX

Hello ,I am new in VUEX . I know that for using 2 ways data binding in my form , I have to do this -

<label>Name</label>
 <input class="input" type="text"  v-model="name"  >

<label>E-mail</label>
 <input class="input" type="text"  v-model="email"  >

AND THE COMPUTED PROPERTY

 name: {
                get() {

                    return this.$store.getters['register/form']['name'];
                },
                set(value) {
                    return this.$store.dispatch('register/setForm', {value: value, name: 'name'});
                }
            } ,
email: {
                get() {

                    return this.$store.getters['register/form']['email'];
                },
                set(value) {
                    return this.$store.dispatch('register/setForm', {value: value, name: 'email'});
                }
            } ,

WELL , If my form is to big this computed property will get very BIG . could I make something like that ?

<label>Name</label>
 <input class="input" type="text"  v-model="form['name']"  >

<label>E-mail</label>
 <input class="input" type="text"  v-model="form['email']"  >

AND THE COMPUTED PROPERTY , WOLD BE SOMETHING SHORTER LIKE THIS -

form(): {
                get(FormName) {

                    return this.$store.getters['register/form'][FormName];
                },
                set(value , FormName) {
                    return this.$store.dispatch('register/setForm', {value: value, name: FormName});
                }
            } ,

Thanks

Activity icon

Replied to VUEX , Getters With The Same Name In Different Modules

I solved , it is just use this

 namespaced:true ,