murilo

murilo

Member Since 3 Years Ago

Ribeirão Preto

Experience Points
30,400
Total
Experience

4,600 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
252
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
30,400 XP
18 Sep
4 days ago

murilo left a reply on 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 ?

17 Sep
5 days ago

murilo 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 ?

16 Sep
6 days ago

murilo 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

08 Sep
2 weeks ago

murilo 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

07 Sep
2 weeks ago

murilo left a reply on 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 .

murilo 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 ?

31 Aug
3 weeks ago

murilo 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 ?

25 Aug
4 weeks ago

murilo 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
    } ,

murilo 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);
24 Aug
4 weeks ago

murilo 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

murilo left a reply on VUEX , Getters With The Same Name In Different Modules

I solved , it is just use this

 namespaced:true ,
20 Aug
1 month ago

murilo started a new conversation VUEX , Getters With The Same Name In Different Modules

Hello Guys , I am trying to organilzing my projects and starting making all single applications . I have some doubt about VUEX . I am separating STORE in modules , in those modules I have getters and states with the same name , when I call it in the blade , it call all those getters without separete it . I wold like to call just a specific getter from that module . like this -

 ...mapGetters({
                name_getter: 'name_of_module/name_getter'
            })

but it is not calling like that .

THIS IS MY CODE -

STATE FILE -

import register from './modules/post';
import register from './modules/postCategory';

export default new Vuex.Store({
    modules: {
        post
    postCategory
    }

});

POST CATEGORY STATE MODULE

const state = {
    post_category: {title:'' , id:''} ,
    form_errors: {}
}

const getters = {
    form_errors: form_errors=> {
        return state.form_errors;
    } ,

POST STATE MODULE

const state = {
    post: {title:'' , id:''} ,
    form_errors: {}
}

const getters = {
    form_errors: form_errors=> {
        return state.form_errors;
    } ,

AND I CAN CALL THE GETTER LIKE THIS IN THE CONSTRUCTOR


            ...mapGetters({
                form_errors: 'form_errors'
            })

the problem that I have more than one getter with the same name ( POST / form_errors AND POST CATEGORY / form_errors ) , if I make like this , it will show just one .

I tryed like this -


            ...mapGetters({
                form_errors: 'postCategory/form_errors'
            })

but didnt work , wold be a best practice have diferent names of getters in my project ? It is that abble to reach a getter with the same name in different module ?

thanks

06 Aug
1 month ago

murilo started a new conversation VUE Authentication Token For Many Type Of Users ( Multh Authentication )

Hello , I am starting making my application all SPA ( single page application ) , with VUE + Laravel . I have been watching some videos , I did something based on this video - https://www.youtube.com/watch?v=Jd1RW-0lQOs&list=PLJpBh2VJhy5wPhAmjDB42pkHUnqolqxxq

I have in my project a user Authentication API with JWT Class and Laravel , That I check if the user exists by his email and password . If do exists , so it returns a token , and I add this code in the header of the page with axios in VUE , like that -

axios.defaults.headers.common['Authorization'] = `Bearer ${token}`

Well , this is ok . but how do I make to have different types of users , for example -

ADMIN - USERS
CUSTOMER  - USERS

How could I prevent , the customer user to get logged in with his token , and after go to admin area and have the entire access to the admin area content ?

17 Jul
2 months ago

murilo started a new conversation Is A Web Single Application Less Indexed For Google ?

Hello Guys , I have question . I am developing a project in Laravel + VUE . I am thinking in using VUE CLI , and make it a single web application . but in this project , I will neeed a lot to be well ranked in google . if I make it in single application . Will this website be less indexed by google ?

Thanks

18 Jun
3 months ago

murilo started a new conversation Desabilitate Foreign Key And DROP ALL TABLES IN POSTGREE

Hello guys , I have this comman that I use in Laravel , that desabilitate foreign key , and delete .

     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        foreach (ResetMigrationTables::getAll() as $table){
            Schema::dropIfExists($table);
        }

        Schema::dropIfExists('migrations');

        DB::statement('SET FOREIGN_KEY_CHECKS=1;');

those commands works in mySQL -

DB::statement('SET FOREIGN_KEY_CHECKS=0;');
...
DB::statement('SET FOREIGN_KEY_CHECKS=1;');

IN Postgree I dint find any command like this that can desabilitate the forner key , to I delete alll I tryed this one

  Schema::disableForeignKeyConstraints();
  Schema::enableForeignKeyConstraints();

But does not work , does some one had the same problem ?

14 Jun
3 months ago

murilo started a new conversation It Is That Possible To Gerate A New Class With A Custom Artisan Command ?

Hello Guys , I have a question . It is that possible to gerate a new class with a custom artisan command ?

I now how to create a custom command in artisan , but my question is how to gerate a PHP file . I wold like to make something like that -

    php artisan gerate:customClass

in console\Commands\gerateClass

 protected $signature = 'gerate:customClass';

protected $description = 'Gerate new Class';


 public function handle()
    {
        // create a php file
        $path = '\Classes\CustomClasses\MyClass';
        

        $class_template = '
            
            
                
             public function doThis()
                {
            ........
            }
                
        ';
}

07 Jun
3 months ago

murilo left a reply on Laravel Many Custom Requests

I wold like to make separated , if I make togueder , It works . but separated . I does not works .

murilo started a new conversation Laravel Many Custom Requests

Hello Guys , I usaly make custom laravel request like this -

THIS way it works 

public function rules()
    {
        return [
            'email'                => ['required'  , new VerifyIfThisEmailDoesNotExist()] ,
            'name'              => 'required'
        ];
    }

But I am trying to use many custom classes in just one field , and it is not working . like this -

THIS way dont works 

public function rules()
    {
        return [
            'email'                => ['required'  , new VerifyIfThisEmailDoesNotExist() , new VerifyIfThisEmailisGmailAccount( ) , ] ,
            'name'              => 'required'
        ];
    }

It is only possible to use one custome class for fields ?

06 Jun
3 months ago

murilo started a new conversation One Larave Application , Many Databases

Hello Guys , I work for a company that sells a desktop PDV Software ( a software that shows sales , process orders , taxes ... ) for companies . Well , This place that I work wants to make a online version of this software , but in this software . it has one database for each company , becose it is a huge database for each company . It is that posible to connect a laravel application with many databases , each client having one database ? It is a good approach ? Thanks

04 May
4 months ago

murilo started a new conversation Form Validation Rule When Updating Pass ID Value

hello , I have a a question about form Validation Rule . Can I pass more than one value to this class ? My Rule validation class , verify -

IF IS CREATING -
* If it has NOT other product with the same title .

IF IS UPDATING -
* If it has NOT other product with the same title .
* if is the same ID of the product that I am updating  , IT will not verify if has the same title of that product .

I wold Like to pass the ID , when I update .

I have form request like this -


use App\Rules\VerifyTitleExists;

... 

 public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title'               => [ 'required' , new VerifyTitleExists ] ,
            'price'               => 'required' ,
            'category_id'         => 'required' ,
        ];
    }

And a Rule Validation -

use App\Product;

     public function __construct()
    {
        //
    }

    public function passes($attribute, $value)
    {
    
    // how could I get this $id value ?         

    // IT IS UPDATING 
    if($id){

           return Product::where('title' , $value)->where('id' , '!', $id)->first() ?  false
                                                                                                  :  true;  

    }

    // IS CREATING
        // IF TITLE EXISTS RETURN FALSE
        return Product::where('title' , $value)->first() ?  false
                                                                           :  true;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'This Title  Already Exists , Chose Another One ';
    }


WHat wold be the best whay to do that ? It is that possible to send the ID value to the Rule Class ?

Thanks

03 May
4 months ago

murilo left a reply on I Cant Connect Mysql .env Production

Thanks @jlrdw , It is working now . I found the error

I created a new user , now like this -


CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'js7634ld';
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost' WITH GRANT OPTION;


after a new db

CREATE DATABASE new_db;
USE new_db;

Now it is working , thanks

murilo left a reply on I Cant Connect Mysql .env Production

hello @jlrdw . if I try to make the migration . It gives this error -

SQLSTATE[HY000] [1045] Access denied for user 'm_user1'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = post_test and table_name = migrations)


 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'm_user1'@'localhost' (using password: YES)")
      /var/www/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=localhost;port=3306;dbname=post_test", "msantos", "hsd", [])
      /var/www/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70


murilo started a new conversation I Cant Connect Mysql .env Production

Hello , Please . some one can help me ? I am trying to deploy a website in this server - vultr.com .

Well , I had donne everthing correctly , but It is not connecting to database . I using Nginx / Laravel 5.8 / PHP 7.2

this is my .env

APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:gyo6oWaubavzqyQNRfH9TEvn0Pbnmfg2345Slfo=
APP_DEBUG=false
APP_URL=http://144.202.33.87

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=post_test
DB_USERNAME=m_user1
DB_PASSWORD=hHHkd123


this is the log error -

    [2019-05-03 21:37:24] production.ERROR: SQLSTATE[HY000] [1045] Access denied for user 'm_user1'@'localhost' (using password: YES) (SQL: select count(*) as aggregate from `posts`) {"exception":"[object] (Illuminate\Database\QueryException(code: 1045): SQLSTATE[HY000] [$
[stacktrace]

I can access this database using

     mysql -u m_user1 -p 'post_test'

and after , type my password . I access successfuly .

my database is like this -

+----------------------+
| Tables_in_post_test  |
+----------------------+
| post_categories      |
| posts                |
| migrations           |
+----------------------+
3 rows in set (0.00 sec)

But I cant connect , with laravel . maybe my .env is rong . do I use APP_ENV=production ?

I alredy tried -

php artisan config:cache
php artisan dump-autoload
php artisan config:cache
php artisan route:clear

18 Apr
5 months ago

murilo left a reply on Cloning My Project , NPM Is Not Rendering All The Js Code Properly

Hello Guys , I solved the problem , after 2 days trying many ways , now it is working . I just copped the the node_modules , folder from the old project into the new one .

@siangboon , I did like that - I just installed the same version of laravel , copped all those folders that I had in the last project . and copped as well the - node_modules Folder , and I did the command -

    npm run dev

so now It is working . Thanks every one .

17 Apr
5 months ago
16 Apr
5 months ago

murilo started a new conversation Cloning My Project , NPM Is Not Rendering All The Js Code Properly

Hello Guys , I have a problem here that I dont know how to solve . I have a website that I created , It is in laravel 5.6 and VUE js , if I try to render the javascript code in this folder , it will render properly , I can render by this command -

    npm run dev 

well , I recently tried to clone this project in other machine , I created succesfuly , but the javascript is not rendering properly .

Then I created a new project in my machine , and copied the same project , the same version of laravel , same version of npm , and cloned the project , and it gave the same error when I tried to render by this command -

    npm run dev

It does not gives any error , but it is not render properly some codes , that are more complex . I dont know what is happening , had this happed with some one ? I dont know what to do .

31 Mar
5 months ago

murilo started a new conversation NPM Run - Is Not Rendering A JS File Properly

Hello GUYS , I have been all day trying with many ways to solve a problem . I have a project that I created inside XAMP Host ( in my machine , windows ) , then I started working with docker ( Laradock ) and I created the same project inside the laradock host .

Well , it is working , but when I created the Javascript with -

npm install
npm run dev

It seens that some classes in javascript was not rendered properly , javascript classes like this ones -

https://laracasts.com/series/learn-vue-2-step-by-step/episodes/20

It is not working properly , I am using -

npm vesion - 6.7.0
node version - 11.12.0


the old project was with laravel 5.6 and this one with laravel 5.8

maybe , it is rendering in a strict mode , does have any configuration that I set strict or not strict ?

Thanks a lot

16 Mar
6 months ago

murilo left a reply on Detect Outside Event Does Not Work Inside VUE Modal

I realized that happens becose I used this function inside VUE Modal -

@click.stop

<div class="modal-wrapper"    @click="$emit('close')" >

                                    <div :class="modalStyle" @click.stop >

                    ....
                    </div>

</div>

To detect when click outside the modal - close the modal . I fixed thanks ,

murilo started a new conversation Detect Outside Event Does Not Work Inside VUE Modal

Hello guys , I did a drop down compoennt that open , if click inside and close if click outside . I used this function to detect INSIDE / OUTSITE -

https://jsfiddle.net/Linusborg/yzm8t8jq/

this is the image of my component - https://ibb.co/WxVPrCY

It works , but I tried to use this inside VUE Modal , and this function to detect inside / outside the compoent , does not work inside the VUE modal .

I wold like to detect a click inside the VUE Modal , but NOT inside my component , or outside the component . Does any one there had the same problem ?

Thanks

29 Dec
8 months ago

murilo started a new conversation Count Posts Where Tag = 1

Hello , I have a question .

I have this code , It is working -

CATEGORY CONTROLLER

       return  CategoryPost::select(['id' ,'title'])
        ->withCount('Posts')
->get();

CATEGORY MODEL

  public function Posts(){
        return $this->hasMany(Post::class , 'category_id' );
    }

BUT I want to count all the posts in this category with TAG = 1 .

It wold be something like that -

CATEGORY CONTROLLER

       return  CategoryPost::select(['id' ,'title'])
        ->with('CountPostWithTagOne')
->get();

CATEGORY MODEL

  public function Posts(){
        return $this->hasMany(Post::class , 'category_id' );
    }

  public function CountPostWithTagOne(){
        return $this->Posts->where('tag_id' , 1 )->count();
    }

But this second example does not work .

19 Dec
9 months ago

murilo left a reply on Searching , And Change The Result / Json Decode .

@REALRANDYALLEN - Hello @REALRANDYALLEN , not realy , I have more Items in this query . It wold be betther that I could keep the eloquent structure . but was a good Ideal . Thanks

murilo started a new conversation Searching , And Change The Result / Json Decode .

I dont know if this is possible , I am getting a Json decode search and using this VUE js . like this -

  $post = Post::select(['id', 'status' , 'title'  , 'description'])->get();

   return response()->json([ $post ]);

I wold like to change my search , using -


str_limit('description', 40) in the description field

something like that -


  $post = Post::select(['id', 'status' , 'title'  , str_limit('description', 40) ])->get();

   return response()->json([ $post ]);


Thanks

13 Dec
9 months ago

murilo left a reply on Set Data In VUE Dinamic

@WILK_RANDALL - I worked , thanks

murilo started a new conversation Set Data In VUE Dinamic

Hello I have a quention , I have a code , That sets diffent datas . is like this ->

if(data.type == "message"){
    this.message = data.result; 
}

if(data.type == "info"){
    this.info = data.result; 
}

if(data.type == "post"){
    this.post = data.result; 
}

How could I make this code dinamic, something like this -

    this[data.type] = data.result; 



Thanks

murilo left a reply on Enable And Desable Appends In A Laravel Search

@LOSTDREAMER_NL - I am using Laravel 5.6 , and it is not working this ->

$result->append('is_liked');

or

$result->append('is_liked')->get();


or

$result->append('is_liked')->all();

murilo left a reply on Enable And Desable Appends In A Laravel Search

@CRONIX - Thanks CRONIX , I tryed to make my search using append like this ->

$result->append('is_liked');

But , didnt worked -

Method Illuminate\Database\Eloquent\Collection::append does not exist.

murilo started a new conversation Enable And Desable Appends In A Laravel Search

Hello , I just discovered working with appends in my Model . I have been working with Vue js , and I have been working to mutch with Json request searches . In some cases I have to use Appends in my model to get some results in my search , like this -

CONTROLLER ->

 $result  = Post::select(['id', 'title' , 'description'])->get()

  return response()->json($result) .

MODEL ->


class POST extends Model
{
    protected $appends = ['is_liked'];

public function getIsLikedAttribute() 
    {
        return $this->likes->where('user_id', auth()->id())->count() > 0;
    }

    }

THE RESULT WILL BE LIKE THIS ->

[{ "id":1 , "title":title , "description":post_description ,"likes":true , .... } ,
  { "id":2 , "title":other title , "description":other post_description ,"likes":false , .... }]

How could I desable appends in my search ? or just use this when I want ?

12 Dec
9 months ago

murilo left a reply on Select Query Posts With Likes

@LOSTDREAMER_NL - Thanks my frined , now it worked .

murilo left a reply on Select Query Posts With Likes

Thanks , @lostdreamer_nl , It shows like that - I can do like this ->


 // WITH LIKES
            ->with([ 'likes' => function($query) {
                
                         $query->where('user_id', '=', $this->user->id);
                 
            } ])


It shows like that ->

[{ "id":1 , "title":title , "description":post_description ,"likes":[{"post_id":44,"user_id":22}] , .... } ,
  { "id":2 , "title":other title , "description":other post_description ,"likes":[] , .... }]

can I make something to shows TRUE or FALSE instead ? like this -

[{ "id":1 , "title":title , "description":post_description ,"likes":true , .... } ,
  { "id":2 , "title":other title , "description":other post_description ,"likes":false , .... }]

11 Dec
9 months ago

murilo left a reply on Select Query Posts With Likes

Thanks very mutch for the help @lostdreamer_nl and @drfraker , in both examples it uses that -

foreach($posts as $post) {
    echo $post->id ." = ". $post->is_liked ."\r\n";
}

I can not make like that , I am using JSON REQUEST , I am not displaying on the VIEW , so I need to bring all those results like this in my CONTROLLER becose I am using all those results in VUE Js ->


 $result  = Prop::select(['id', 'title' , 'description'])

    // LIKED , IT SAYS TRUE OR FALSE
            ->with([ 'Like' => function($query) { 
                       
            } ])->get()

  return response()->json($result) .

murilo started a new conversation Select Query Posts With Likes

Hello , I have a question , I am developing a website like a facebook . It will have POSTS and a User can LIKE those posts ,

So a user can search all those posts , if this post is LIKED ( this user has given a like ) , so it has to show that this post is liked .

The like and POST is related by Many to MAny relation ship .

Will be like that -

POST MODEL

 // LIKE
    public function Like() {
        return $this->belongsToMany(User::class , 'user_post_likeble' , 'post_id'  , 'user_id');
    }


POST QUERY RESULT ->


  $result  = Prop::select(['id', 'title' , 'description'])

    // LIKED , IT SAYS TRUE OR FALSE
            ->with([ 'Like' => function($query) {
                // I dont know how could I make the relation ship here to say TRUE for those one that has relation chip / FALSE for those one that dont has relation ship .                 

            } ])->get()



Thanks .

murilo started a new conversation ACL In Laravel , Auth

Hello , I am trying to make a ACL auth in Laravel like this tutorial - https://laracasts.com/series/whats-new-in-laravel-5-1/episodes/13

It is working , I have all my users in the same table ( USERS table ) and its use the same guard , they are divided by roles , like this -

ADMIN - $user->hasRole('admin') CLIENTS - $user->hasRole('client') ....

In the login auth / verification , I have to make like this ->

//  search the user 
  $user =  User::where('email' , $request['email'] )->first();

// if has user and the user is admin 
if(! $user || ! $user->hasRole('admin')  ) {

// start making credentials
 $credentials = ['email' => $request['email'], 'password' => $request['password']];

    // verify again
        if(auth()->guard()->attempt($credentials)){

          return true;

        }


Does have any better way to do that ? something like this ->



// start making credentials
 $credentials = ['email' => $request['email'], 'password' => $request['password']];

    // verify again
        if(auth('admin')->guard()->attempt($credentials)){

          return true;

        }

02 Dec
9 months ago
26 Nov
9 months ago

murilo left a reply on Verify Password Is The Same , And Update It .

Hello @kiruba , @zymawy , @BezhanSalleh , I can see that is using Hash:: Instead the bcript() . To incript my password , do I use Hash:: instead bcript as well ? is that more , or less secure than bcript() ?

25 Nov
9 months ago

murilo started a new conversation Verify Password Is The Same , And Update It .

Hi , I am trying to update the password of the user . But before update , the user must type the same password , like this -

  1. verify if the current password is the same .
  2. update the password . ( new one )

I am making like this ->

 if( $this->password !=  bcrypt($request['password'])){
            return true;
        }


But It is not working like this with bcrypt() .

Does some one knows how could I do it ?

Thanks

01 Nov
10 months ago

murilo left a reply on I Cant Understand Fluent Interfaces

@jlrdw , do you think that is posible to make static like this ->

$foo = Foo::setThing('thing')->setOtherThing('other_thing')->save();

How could I make here -


 public  static function setThing($thing)
    {

        $this->thing= $thing;
        return $self;

    }

Thanks

31 Oct
10 months ago

murilo left a reply on I Cant Understand Fluent Interfaces

I discovered how to make this ->

    $foo = new Foo();
       return  $foo->setThing('thing')->setOtherThing('other_thing')->save();

the class will be like this ->


class Foo
{
    protected $thing;
    protected $other_thing;

    public  function setThing($thing)
    {

        $this->thing= $thing;
        return $this;

    }

   public  function setOtherThing($other_thing)
    {

        $this->other_thing= $other_thing;
        return $this;

    }


    public  function save()
    {

            return this->thing  ." and ". $this->other_thing . "are saved";
    }

}

Ok it is working , but how could I make this class static ?

Instead this -

    $foo = new Foo();
       return  $foo->setThing('thing')->setOtherThing('other_thing')->save();

Make something like this ->

    $foo = Foo::setThing('thing')->setOtherThing('other_thing')->save();

is that possible ?

30 Oct
10 months ago

murilo started a new conversation I Cant Understand Fluent Interfaces

I saw this tutorial using Fluent Interfaces , it is very good and practical to organize codes - https://laracasts.com/series/whip-monstrous-code-into-shape/episodes/14

But I could not understand how fluent interfaces works .

Does some one can help me please ?

I wold like to do something like this ->

Foo::create()->setThing('thing');