mstdmstd

mstdmstd

Member Since 2 Years Ago

Experience Points 10,300
Experience Level 3

4,700 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 2
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

18 May
3 days ago

mstdmstd left a reply on I Have Event Duplication After Action Was Moved In Store Object

I still search for valid decision : I uploaded live demo at : http://178.128.145.48/login [email protected] wdemo

http://178.128.145.48/websites-blogs will be opened. Please, try to go to “User's lists” by link at top left menu https://prnt.sc/nq4qiy and back several times. When on “User's lists” page I try to delete 1 user list it is deleted, but I got several messages and url in “network” section of my browser : https://imgur.com/a/4ubFB0g Looks like events are duplicated. And looks like that is move between pages number of guplications is raised. Why and how to fix it ? I use @click.prevent in triggering the event to show confirm delete message.

There is “ Add Demo Data” to add more demo rows.

16 May
5 days ago

mstdmstd left a reply on In Axios Request I Got Has Been Blocked By CORS Policy Error

I payed attention that with internal request I see token : https://imgur.com/a/nFNwGs2 But in external request I do not see this токена : https://imgur.com/a/7sS7FtN

Could that be the issue?

I tried to add token manually(I check it in alert ):

                alert( "app_url::"+var_dump(this.app_url) + "  this.currentLoggedUser::"+var_dump(this.currentLoggedUser) )
                
                axios.post(window.REMOTE_SEARCH_WEB, {
                    "query": "pc gamers",
                    "blogger": false,
                    "company": false,
                    "influencer": false,
                    "article": false,
                    "pageId": 1,
                    "sort": null,
                    "sortOrder": null,
                    "searchType": 1,
                    "X-XSRF-TOKEN": this.currentLoggedUser.token,

But I do not see the token in external request. Which is the right way ?

15 May
6 days ago

mstdmstd left a reply on In Axios Request I Got Has Been Blocked By CORS Policy Error

I installed https://github.com/barryvdh/laravel-cors package and

  1. in file I added line in app/Http/Kernel.php
protected $middleware = [
    // ...
    \Barryvdh\Cors\HandleCors::class,
];

I added in middleware group I that is is not ‘/api’ internal, but external request. Is it correct?

  1. I left file config/cors.php without changes :
<?php

return [

    'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedOriginsPatterns' => [],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['*'],
    'exposedHeaders' => [],
    'maxAge' => 0,

];
  1. In axios.post request I removed all Access-Control parameters
        axios.post(window.REMOTE_SEARCH_WEB, {
            "query": "pc gamers",
            "blogger": false,
            "company": false,
            "influencer": false,
            "article": false,
            "pageId": 1,
            "sort": null,
            "sortOrder": null,
            "searchType": 1,
        }).then((response) => {
  1. But the same error in request : https://imgur.com/a/wbgmrps

What is wrong ?

14 May
1 week ago

mstdmstd started a new conversation In Axios Request I Got Has Been Blocked By CORS Policy Error

Hello, In laravel 5.8 / "vue": "^2.5.17" / "axios": "^0.18" I need to read external data which are read from postman ok : https://imgur.com/a/SRBmK0P

I try to read these data using axios and got error: https://imgur.com/a/o97xLm7

in browse I see details of the request : https://imgur.com/a/EUkyV43

My JS code:

        axios.post(window.REMOTE_SEARCH_WEB, {
            "query": "pc gamers",
            "blogger": false,
            "company": false,
            "influencer": false,
            "article": false,
            "pageId": 1,
            "sort": null,
            "sortOrder": null,
            "searchType": 1,
            "Access-Control-Allow-Origin": this.app_url,
            "Access-Control-Allow-Methods": "POST",
            "Access-Control-Max-Age": 86400,
            "Access-Control-Allow-Headers": "Content-Type, Authorization",
            'Access-Control-Allow-Credentials': 'true'
        }).then((response) => {

where this.app_url is home url of the site the app run at. Googling I found several parameters Access-Control-* must be filled, like in code above, but that did not help me. Can you say how I to fix it?

  1. can it be that a desicion could be from my js code with axios to run action in my control and from there to make request using php/laravel ? If yes, please provide example of such decision...

Thanks!

mstdmstd left a reply on "continue" Targeting Switch Is Equivalent To "break" Error Under Php 7.3

I found this https://medium.com/andrewmmc-io/upgrade-php-version-to-7-2-from-7-0-c005a0926642 instruction but got error in console :

# apt-get install php7.2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php7.2 is already the newest version (7.2.18-1+ubuntu16.04.1+deb.sury.org+1).

?

mstdmstd left a reply on "continue" Targeting Switch Is Equivalent To "break" Error Under Php 7.3

Running sudo update-alternatives --set php /usr/bin/php7.2 I got in console:

# php -v
PHP 7.2.18-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  3 2019 09:23:41) ( NTS )

but phpinfo in browser shows :

PHP Version 7.0.33-0ubuntu0.16.04.4

How to refresh it?

13 May
1 week ago

mstdmstd left a reply on "continue" Targeting Switch Is Equivalent To "break" Error Under Php 7.3

I got error :

[email protected]:~# php composer.phar self-update
Could not open input file: composer.phar
[email protected]:~# sudo -H composer self-update

                                         
  [InvalidArgumentException]             
  Command "self-update" is not defined.

Is it valid command ?

mstdmstd left a reply on "continue" Targeting Switch Is Equivalent To "break" Error Under Php 7.3

I have old composer : Composer version @package_branch_alias_version@ (1.0.0-beta2) 2016-03-27 16:00:34 . How to raise it?

mstdmstd started a new conversation "continue" Targeting Switch Is Equivalent To "break" Error Under Php 7.3

Hello, I install laravel 5.8 on new Ubuntu 16 instance under Digital Ocean. I need to install php 7.2 and for this I run commands:

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update 
sudo apt-get remove php7.0
sudo apt-get install php7.2

I was very surprosed that I found php 7.3:

# php -v
PHP 7.3.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  3 2019 10:00:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

After that I got error on composer installing:

# composer  install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

                                                                                           
  [ErrorException]                                                                         
  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?  

Googling I found that it is some specific php7.3 error and I wonder which can be decision here? To downgrade to php7.2(If yes how better to make it?)

Or some other decision ?

Thanks!

12 May
1 week ago

mstdmstd left a reply on I Have Event Duplication After Action Was Moved In Store Object

It seems that my events structure appeared rather complicated, but it seems to me that I followed vuejs common rules. Any ideas how to fix events duplication ? I use @click.prevent=" but that does not help in my case ...

mstdmstd started a new conversation I Have Event Duplication After Action Was Moved In Store Object

Hello, In my laravel 5.8 / vue 2.5.17 / vuex^3.1.0 I have a problem that with dialog opened I have event duplication. I have an event for item deletion :

In my vue file:

    <i :class="'mr-2 '+getHeaderIcon('delete')" @click.prevent="confirmDeleteUserList( nextUserList.id, nextUserList.title, index );"></i>
    ...

        mounted() {

            bus.$on('dialog_confirmed', (paramsArray) => {
                if (paramsArray.key == this.deleteFromUserListsKey(paramsArray.user_list_id)) {
                    this.runDeleteFromUserLists(paramsArray.user_list_id, paramsArray.index);
                }
            })
            bus.$on('onUserListDeleteSuccess', (response) => {
                this.is_page_updating = false
                this.showPopupMessage("User lists", 'User\'s list was successfully deleted!', 'success');
            })

            bus.$on('onUserListDeleteFailure', (error) => {
                this.$setLaravelValidationErrorsFromResponse(error.message);
                this.is_page_updating = false
                this.showRunTimeError(error, this);
                this.showPopupMessage("User lists", 'Error adding user\'s list !', 'error');
            })


        }, // mounted() {

        methods: {
            confirmDeleteUserList(user_list_id, user_list_title, index) {
                this.confirmMsg("Do you want to exclude '" + user_list_title + "' user list ?", {
                    key: this.deleteFromUserListsKey(user_list_id), user_list_id: user_list_id, index: index
                }, 'Confirm', bus);
            }, //confirmDeleteUserList(id, user_list_title, index) {

            deleteFromUserListsKey(user_list_id) {
                return 'user_list__remove_' + user_list_id;
            },

            runDeleteFromUserLists(user_list_id, index) {
                this.$store.dispatch('userListDelete', { logged_user_id : this.currentLoggedUser.id, user_list_id : user_list_id } );
            }, // runDeleteFromUserLists()  {

and in resources/js/store.js :

    state : {
        ...        
        userLists: [],
        ...        
    actions : {


        userListDelete(context, paramsArray ) {
            axios({
                method: ( 'delete' ),
                url: this.getters.apiUrl + '/personal/user-lists/' + paramsArray.user_list_id,
            }).then((response) => {
                let L = this.getters.userLists.length
                for (var I = 0; I < L; I++) {
                    if (response.data.id == this.getters.userLists[I].id) {
                        this.getters.userLists.splice(this.getters.userLists.indexOf(this.getters.userLists[I]), 1)
                        context.commit('refreshUserLists', this.getters.userLists);
                        break;
                    }
                }

                bus.$emit( 'onUserListDeleteSuccess', response );
            }).catch((error) => {
                bus.$emit('onUserListDeleteFailure', error);
            });

        }, // userListDelete(context, paramsArray ) { 

confirmMsg (based on https://github.com/euvl/vue-js-modal )is defined in my mixing :

        confirmMsg: function (question, paramsArray, title, bus) {
            this.$modal.show('dialog', {
                title: title,
                text: question,
                buttons: [
                    {
                        title: 'Yes',
                        default: true,    // Will be triggered by default if 'Enter' pressed.
                        handler: () => {
                            bus.$emit('dialog_confirmed', paramsArray);
                            this.$modal.hide('dialog')
                        }
                    },
                    {
                        title: '',       // Button title
                        handler: () => {
                        } // Button click handler
                    },
                    {
                        title: 'Cancel'
                    }
                ]
            })
        },

it worked ok, until I moved userListDelete method from my vue file into store.js. As a result on 1st event item is deleted ok, the the second item raise error that item was not found and I do not know event is doubled...

How to fix it ?

Thanks!

08 May
1 week ago

mstdmstd started a new conversation Why Suffer Error Running Migration Under Vultr Vps

Hello, Installing and running migration my laravel 5.8 app on new server under vultr vps I got error: https://imgur.com/a/87KgTQ4

php info is here : http://phpstack-231450-837582.cloudwaysapps.com/

How fix this error ?

Thanks!

01 May
2 weeks ago

mstdmstd started a new conversation Installing Install Jwt-auth I Got Error Carbon Conflict

Hello, In my new Laravel 5.8.15 I tried to install jwt-auth and got error:

 composer require tymon/jwt-auth
Using version ^0.5.12 for tymon/jwt-auth
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for tymon/jwt-auth ^0.5.12 -> satisfiable by tymon/jwt-auth[0.5.12].
    - Conclusion: remove nesbot/carbon 2.17.1
    - Conclusion: don't install nesbot/carbon 2.17.1
    - tymon/jwt-auth 0.5.12 requires nesbot/carbon ~1.0 -> satisfiable by nesbot/carbon[1.0.0, 1.0.1, 1.1.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0, 1.14.0, 1.15.0, 1.16.0, 1.17.0, 1.18.0, 1.19.0, 1.2.0, 1.20.0, 1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.3.0, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.4.0, 1.5.0, 1.6.0, 1.7.0, 1.8.0, 1.9.0].
    - Can only install one of: nesbot/carbon[1.26.3, 2.17.1].
    - Can only install one of: nesbot/carbon[1.26.4, 2.17.1].
    - Can only install one of: nesbot/carbon[1.27.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.28.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.29.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.29.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.29.2, 2.17.1].
    - Can only install one of: nesbot/carbon[1.30.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.31.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.31.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.32.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.33.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.34.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.34.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.34.2, 2.17.1].
    - Can only install one of: nesbot/carbon[1.34.3, 2.17.1].
    - Can only install one of: nesbot/carbon[1.34.4, 2.17.1].
    - Can only install one of: nesbot/carbon[1.35.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.35.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.36.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.36.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.36.2, 2.17.1].
    - Can only install one of: nesbot/carbon[1.0.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.0.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.1.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.10.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.11.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.12.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.13.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.14.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.15.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.16.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.17.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.18.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.19.0, 2.17.1].                                                                                                                                                          
    - Can only install one of: nesbot/carbon[1.2.0, 2.17.1].                                                                                                                                                           
    - Can only install one of: nesbot/carbon[1.20.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.21.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.22.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.22.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.23.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.24.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.24.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.24.2, 2.17.1].
    - Can only install one of: nesbot/carbon[1.25.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.26.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.26.1, 2.17.1].
    - Can only install one of: nesbot/carbon[1.26.2, 2.17.1].
    - Can only install one of: nesbot/carbon[1.3.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.4.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.5.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.6.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.7.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.8.0, 2.17.1].
    - Can only install one of: nesbot/carbon[1.9.0, 2.17.1].
    - Installation request for nesbot/carbon (locked at 2.17.1) -> satisfiable by nesbot/carbon[2.17.1].

Installation failed, reverting ./composer.json to its original content.

I am not sure which steps have I to do to install jwt-auth ?

Thanks!

29 Apr
3 weeks ago

mstdmstd started a new conversation Severa Similar

Hello, Working with Laravel 5.7 / Vuejs 2.6 /Vuex 3.1 app I have bookmarks functionality for logged user on several pages, which are implemented with methods like

            runAddToBookmarks(hostel_id)  {
                this.message = '';
                    this.is_page_updating = true
                    axios({
                        method: ( 'post' ),
                        url: window.API_VERSION_LINK + 'personal/personal_hostel_bookmarks',
                        data: { user_id : this.currentLoggedUser.id, hostel_id: hostel_id,  },
                    }).then((response) => {
                        this.personalHostelBookmarks.push({  "hostel_id": hostel_id, "name": "", "phone": "", "": "", "feature": "S", "rating": "1", "region_name": "",
                            "state_name": "" } )
                        this.is_page_updating = false
                        this.showPopupMessage("Bookmarks", 'The hostel was added to your bookmarks successfully !', 'success');
                    }).catch((error) => {
                        this.$setLaravelValidationErrorsFromResponse(error.response.data);
                        this.is_page_updating = false
                        this.showRunTimeError(error, this);
                        this.showPopupMessage("Bookmarks", 'Error adding bookmark !', 'error');
                    });
            }, // runAddToBookmarks()  {

            runDeleteFromBookmarks(hostel_id, index)  {
                this.message = '';
                this.is_page_updating = true
                axios({
                    method: ( 'delete' ),
                    url: window.API_VERSION_LINK + 'personal/personal_hostel_bookmarks/' + this.currentLoggedUser.id +"/"+ hostel_id,
                }).then((response) => {
                    var L= this.personalHostelBookmarks.length
                    for (var I= 0; I< L; I++) {
                        if ( hostel_id ==this.personalHostelBookmarks[I].hostel_id ) {
                            this.personalHostelBookmarks.splice( this.personalHostelBookmarks.indexOf(this.personalHostelBookmarks[I]), 1)
                        }
                    }
                    this.is_page_updating = false
                    this.showPopupMessage("Bookmarks", 'The hostel was excluded from your bookmarks successfully !', 'success');
                }).catch((error) => {
                    this.$setLaravelValidationErrorsFromResponse(error.response.data);
                    this.is_page_updating = false
                    this.showRunTimeError(error, this);
                    this.showPopupMessage("Bookmarks", 'Error excluding bookmark !', 'error');
                });
            }, // runDeleteFromBookmarks()  {

I dislike a way to make such methods on any pages(now I have 4 such pages ) and I think that would be good way to put these methods in special mixin and import this mixin in pages when need bookmarks functionality, but in these methods pages vars like this.is_page_updating, this.message are used and that makes mixin decision conplcated. Can be some proper decisions here ? Maybe something like container vue component which is common for such pages? Could you please provide such example with good decision ?

Thanks!

28 Apr
3 weeks ago

mstdmstd started a new conversation Debugging Vue/js In Chromium Browser

Hello, Working with Vuejs 2.6 app in Chromium browser Version 73.0.3683.86 , running on Ubuntu 18.04 (64-bit) I very often got errors in console which are not clear to read, say if piece of code:

<a class="a_link" href="/images/emptyImg.png" v-show="!nextHostel.filenameData.image_url">
   <img class="pull-left single_vote_image_left_aligned" src="/images/emptyImg.png" alt="">
</a>

if filenameData is not defined in nextHostel I see error:

app.js?dt=1556452729:99822 [Vue warn]: Error in render: "TypeError: Cannot read property 'image_url' of undefined"

found in

---> <HostelListItem> at resources/js/components/BS4/lib/HostelListItem.vue
       <HostelsByRegion> at resources/js/components/BS4/HostelsByRegion.vue
         <HostelsByRegion> at resources/js/components/BS4/MainApp.vue
           <Root>

And the same error message with Chrome debugging...

If I try to load the same page under Firefox Quatum 66.0.3 (64bit) I got a bit more descriptive error :

           [Vue warn]: Error in render: "TypeError: _vm.nextHostel.filenameData is undefined" found in ---> <HostelListItem> at resources/js/components/BS4/lib/HostelListItem.vue <HostelsByRegion> at resources/js/components/BS4/HostelsByRegion.vue <HostelsByRegion> at resources/js/components/BS4/MainApp.vue <Root>

it shows that filenameData is not defined for nextHostel.

Actually I prefer Chromium browser for debugging and found it more convinient , but if it possible for Chromium browser to show errors like firefox? Also are there some more plugins/libraries/tricks for vue/js debugging?

Somethimes that is very complicated, as I do not see error number and in console I see that internal code opened, like: https://imgur.com/a/XiKGKvy

I have dev vuejs tools installed, but there is no use with it when erros fixing...

Thanks!

17 Apr
1 month ago

mstdmstd left a reply on How Better Organize Keeping Of Data In Store With Hundreds Hostel Rows

Sorry, I would like to get some help from developers with expierence in centralizing big amount on data on vuex. If there is a way to define : that is the limit and these data are too much for vuex? especcially meaning that vuex is js client library running on different devices... Till now I suppose that point 2) mentioned in my content seems good decision.

As for point 3) I think using of events/websocket could be usefull here, could you please hint some details here ?

14 Apr
1 month ago

mstdmstd started a new conversation How Better Organize Keeping Of Data In Store With Hundreds Hostel Rows

Hello, In my laravel 5.7 / Vuejs 2.6 / "vuex": "^3.1.0"/ bootstrap": 4.3 app I make app with states(8), regions(24), subregions(> 120) and Hostels(supposed there would be several hundrets rows with 35 columns any ). My question is how better organize keeping of data in store? In my store files I have vars defined for data mentioned above:

export default {
    mixins: [appMixin],
    state: {  // data
        currentUser: user,
        ...
        statesList: [],
        regionsList: [],
        subregionsList: [],
        ...
        hostelsList: [],
...

That seems clear with simple statesList, regionsList, subregionsList data - they can be read at first data retrieved and these data are static. But if I have to upload all hostelsList ? That is quote a lot of data. To retrieve them “By need”? In this app any hostel can opened by url of 1 hostel, groups of hostels by state/region/ most rating histels etc... To upload data and to add therm to hostelsList array, with method in store like:

refreshHostelsList(state, payloadHostelsList) {
    alert( "refreshHostelsByRegionIdStateId payloadHostelsList::"+var_dump(payloadHostelsList) )
    console.log("refreshHostelsList::")
    console.log( payloadHostelsList )

    payloadHostelsList.map((nextPayloadHostel, next_key) => { // check which of Payload rows must be added to state.hostelsList
        var L= state.hostelsList.length
        var is_payload_in_state= false;
        for ( var I= 0; I< L; I++ ) {
            if (state.hostelsList[I].id == nextPayloadHostel.id) {
                is_payload_in_state= true;   // payload nextPayloadHostel.id was not in nextPayloadHostel.id - to adde it
                break;
            }
        }
        if ( is_payload_in_state ) {
            state.hostelsList[state.hostelsList.length] = nextPayloadHostel;
        }
    }); // payloadHostelsList.map((nextPayloadHostel, next_key) => { // check which of Payload rows must be added to state.hostelsList

},

But that seems rather complicated. As vuex lib is JS lib all data are kept on client I am afraid that could be memory lack error.

  1. If there is a way to deal it?

  2. Maybe to keep statesList, regionsList, subregionsList in vuex store but without hostelsList and upload data from hostel on page I need them from db? As I meantioned before hostelsList is upoosed rather a big set of data.

  3. Though statesList, regionsList, subregionsList are static but they have active field, so setting active = false, these data must be hidden from frontend. How that could be implemented that when in backend part admin changing state.active = false/true we need to set flag that all clients part stateList must be readred from db ?

Thanks!

11 Apr
1 month ago

mstdmstd left a reply on Vuex In Backend CRUD ?

@MAVERICKCHAN - Which client library you use in backend pages, if any? But as I know vue is also used in backend CRUD operations as client template. But as for vuex ?

mstdmstd started a new conversation Vuex In Backend CRUD ?

Hello, In my laravel 5.7 / Vuejs 2.6 / bootstrap": 4.3 app I want to use vuex and questions is if there is a sense/profit of using vuex in backend?

That is quite ordinary applications : in frontend logged users review proposals, can select proposals and can chat with other users through web sockets. In backend Listing of data with CRUD operations : some of them simple(like category with 1 field) or complicated with structured products and several related tables.

What is your opinion/expierence?

Please links to related topics...

Thanks!

03 Apr
1 month ago

mstdmstd left a reply on PHP Sitemap Generator

@OHFFS - Hello, as I need to reate a sitemap for laravel 5.8 site where there are some common pages , like “Home”, “About”, “Contact Us” and a lot of dynamicallty created pages with slug in url like:"news/main-news-1", "articles/main-article-1" Searching of to ols I found this https://github.com/spatie/laravel-sitemap plugin, which seems quite ok for urls of first type, but I did not find are there functionality to create urls of the second type? If yes, please, point to it. Are there some better tools for it ?

30 Mar
1 month ago

mstdmstd started a new conversation How To Set Password To Laravel Envoy Script?

Hello, In laravel 5.8 I running envoy I want to set password of user in console command, like

envoy run Deploy  --serveruser_password=mypass1112233
Having in envoy file: 
@setup
    $server_login_user= 'serveruser';
    $user_password = isset($serveruser_password) ? $serveruser_password : "Not Defined";

@endsetup
@task( 'clone_project', ['on'=>$on] )
    echo '$user_password password ::';
    echo $user_password;

But $user_password output empty in both cases :

  1. if serveruser_password is set in command
envoy run Deploy  --serveruser_password=mypass1112233
  1. or it is empty
envoy run Deploy

But I expected "Not Defined" outputed...

Why error and how coreect ?

Thanks!

29 Mar
1 month ago

mstdmstd started a new conversation Search Tool For Sitemap Creation Of Dynamically Created Pages

Hello, I need to0 vreate a sitemap for laravel 5.8 site where there are some common pages , like “Home”, “About”, “Contact Us” and a lot of dynamicallty created pages with slug in url like:"news/main-news-1", "articles/main-article-1" Searching of tolols I found this https://github.com/spatie/laravel-sitemap plugin, which seems quite ok for urls of first type, but I did not find are there functionality to creatye urls of the second type? If yes, please, point to it. Are there some better tolls for it ?

Thanks!

25 Mar
1 month ago

mstdmstd left a reply on How Automatic Policy Discovery Can Be Used In Ajax Request ?

Thank you for your feedback! Looks like not or I misuse it.

with method defined in app/Policies/VoteItemUsersResultPolicy.php :

    public function create(User $user)
    {
        return $user->id == auth()->id();
    }

I wanted in my controller to replace code:

      if ( ! Auth::check()) {
            return response()->json([
                'error_code'   => 1,
                'message'      => "To vote you must login to the system !",
                'vote_item_id' =>
                    $requestData['vote_item_id']
            ], HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }

But I got error:

App\Http\Controllers\VotesController::authorize does not exist.

Also I do not find how to return error message.

I googled and did not find any examples of using Policies in ajax requests...

mstdmstd left a reply on How In Envoy Show Debugging Info ?

I see echo command mentioned in 5.0 version documentation : https://laravel.com/docs/5.0/envoy But that does not work in my 5.7/5.8 apps. Is echo still supported in laravel ? Or is that some config option ?

24 Mar
1 month ago

mstdmstd started a new conversation How Automatic Policy Discovery Can Be Used In Ajax Request ?

Hello, Looking at Automatic Policy Discovery features of 5.8 version at https://laracasts.com/series/whats-new-in-laravel-5-8/episodes/1 I try to implement it in my app made in prior Laravel version. I have condition that only logged user can voice for some item(to add new row in VoteItemUsersResult model). and I search how this method can be used with my controller action called by ajax ?

I did it as next method, where I checked valid id parameters and if user is logged.

public function make_vote_selection(Request $request)
    {

        $requestData = $request->all();
        $vote        = Vote::find($requestData['vote_id']);
        if ($vote === null) {
            return response()->json(['error_code' => 1, 'message' => "Vote # " . $requestData['vote_id'] . " not found !", 'vote_id' => $requestData['vote_id']],
                HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }


        $voteItem = VoteItem::find($requestData['vote_item_id']);
        if ($voteItem === null) {
            return response()->json([
                'error_code'   => 1,
                'message'      => "Vote Item # " . $requestData['vote_item_id'] . " not found !",
                'vote_item_id' => $requestData['vote_item_id']
            ],
                HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }

        if ( ! Auth::check()) {
            return response()->json([
                'error_code'   => 1,
                'message'      => "To vote you must login to the system !",
                'vote_item_id' =>
                    $requestData['vote_item_id']
            ], HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }
        $loggedUser = Auth::user();

        $found_count = VoteItemUsersResult
            ::join($this->vote_items_tb, $this->vote_items_tb.'.id', '=', $this->vote_item_users_results_tb.'.vote_item_id')
            ->getByVoteIdAndUserId($requestData['vote_id'], $loggedUser->id)
            ->count();
        if ($found_count > 0) {
            return response()->json([
                'error_code'   => 1,
                'message'      => "You have already voted '" . $vote->name . "' vote # !",
                'vote_item_id' =>
                    $requestData['vote_item_id']
            ], HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }

        $newVoteItemUsersResult = new VoteItemUsersResult();
        try {

            $newVoteItemUsersResult->vote_item_id = $requestData['vote_item_id'];
            $newVoteItemUsersResult->user_id      = $loggedUser->id;
            $newVoteItemUsersResult->is_correct   = $voteItem->is_correct;

            DB::beginTransaction();
            $newVoteItemUsersResult->save();

            $newActivityLog              = new ActivityLog();
            $newActivityLog->description = $loggedUser->username . ' voted ' . ($voteItem->is_correct ? 'correctly' : 'not correctly') . " on '" . $vote->name . "' vote ";
            $newActivityLog->subject_id  = $requestData['vote_id'];
            $newActivityLog->causer_id   = $loggedUser->id;
            $newActivityLog->log_name    = $loggedUser->username;
            $newActivityLog->causer_type = ActivityLog::CAUSER_TYPE_VOTE_SELECTED;
            $newActivityLog->properties  = $voteItem->is_correct; // Vote was correct
            $newActivityLog->save();
            DB::commit();

        } catch (Exception $e) {
            DB::rollBack();

            return response()->json(['error_code' => 1, 'message' => $e->getMessage(), 'voteCategory' => null], HTTP_RESPONSE_INTERNAL_SERVER_ERROR);
        }

        return response()->json(['error_code' => 0, 'message' => '', 'id' => $newVoteItemUsersResult->id], HTTP_RESPONSE_OK_RESOURCE_CREATED);
    } //     public function make_vote_selection(Request $request)

In this method in validation condition

if ( ! Auth::check()) {

is false then error returned in json response.

When I create new policy with command: php artisan make:policy VoteItemUsersResultPolicy -m VoteItemUsersResult

Several methods are generated, and I can ad condition line, like:

public function create(User $user, VoteItemUsersResult $voteItemUsersResult)
{
    return $user->id == $voteItemUsersResult->user_id;
}

But I did not find how this method can be used with my controller action called by ajax ?

Thanks!

mstdmstd started a new conversation How In Envoy Show Debugging Info ?

Hello, Working with envoy in laravel 5.7 I see in examples that echo command is used for debugging purpose.

But whe I write echo in my envoy file, like:

@setup
    $server_login_user= 'lardeployer';

    $timezone= 'Europe/Kiev';

    $path= '/var/www/html/AppDir';

    $current = $path . '/current';

    $repo= '[email protected]:myaccount/votes.git'';

    $branch= 'master';

    echo "Step # 01";
    $writableDirs= [
        '/storage/logs',
        '/bootstrap/cache'
    ];
    echo "Step # 02";
    ...
    echo "Step # 03";

@endsetup

@servers(['production' => $server_login_user.'@NNN.NN.NN.N])


@task( 'clone', ['on'=>$on] )
    ...

running envoy script I do not see any echo messages in my console.

Is this some app option ?

Thanks!

22 Mar
1 month ago

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

Thank you for your help and provided link. Actually what I did was similar to this article, but opening my site in browser I see some different site opened.

My /etc/nginx/sites-available/votes.com :

upstream votes-backend { # Lets you define a group of servers
   server unix:/var/run/php7.2-fpm.sock;
}

server {
   listen 80;
   listen [::]:80;

   root /var/www/votes.com;
   index index.php;

   server_name  nsn.votes.demo.org  www.nsn.votes.demo.org;


   # We keep this block, because it doesn't make sense to pass
   # everything to PHP.
   location / {
      # try_files $uri $uri/ =404;
      try_files $uri $uri/ /index.php index.php;

   }

   location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$; # this defines a regular expression to separate the SCRIPT_FILENAME and PATH_INFO for later use
     try_files $uri =404; # OR Set cgi.fix_pathinfo=0 in php.ini (for security)
     fastcgi_pass votes-backend; # OR unix:/var/run/php7.2-fpm.sock OR 127.0.0.1:9000
     fastcgi_index index.php; # appends index.php to a URI ending with a slash
     include fastcgi_params;
   }

}

where nsn.votes.demo.org url is new created Domain Name - Public hosted zone (I provided a link to it's printscreen)

In /etc/hosts :

127.0.0.1 localhost
127.0.0.2   localhost test.com
#  127.0.0.3   demo1.nilov-sergey-demo-apps.tk
ec2-13-NN-NN-NN.us-east-2.compute.amazonaws.com   nsn.votes.demo.org  www.nsn.votes.demo.org

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Is it valid format ? I checked log files : /var/log/nginx/access.log, /var/log/nginx/error.log, /var/log/php7.2-fpm.log But did not find any errors.

Opening www.nsn.votes.demo.orgin browser I see quite different site opened

and I see ref to this site by console command :

$ curl www.nsn.votes.demo.org
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.untergrund.net">here</a>.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at www.nsn.votes.demo.org Port 80</address>
</body></html>

What is wrong ?

21 Mar
2 months ago

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

@ETTORE - I try first method mentioned by you and I created “sn.votes.demo.org” and I see https://prnt.sc/n1166s with domain names name servers at right.

By documentation “How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04” in your link looks like domain name “nsn.votes.demo.org” I created must be used instead of “example.com” in this article. Is it so ?

20 Mar
2 months ago

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

@CRUORZY - Yes I wrote about it in first topic ; check that /etc/nginx/nginx.conf has links to /etc/nginx/sites-enabled/:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ...
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

dO YOU MEAN THIS ?

mstdmstd started a new conversation Why Grammar::parameterize Adding New Setting Row

Hello, In laravel 5.7 app I got an error on save adding new setting rows I got error :

Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /mnt/_work_sdb8/wwwroot/lar/votes/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 853

In my app I check if there if row in Setting table by name field, if not create it : ``` with(new self)->info( $next_votes_key,'$next_votes_key::' ); $settings = Settings::getByName($next_votes_key)->first(); with(new self)->info( $settings,'$settings::' ); if ($settings === null) { with(new self)->info( "INSIDE",'$::' ); $settings = new Settings(); $settings->name = $next_votes_key; } with(new self)->info( $requestData['votes_' . $next_votes_key],'$requestData['votes_' . $next_votes_key]::' ); $settings->value = $requestData['votes_' . $next_votes_key]; $settings->save();


with(new self)->info that is just wrapper for 
        Debugbar::addMessage($info, $label);


Checking data above I see that $next_votes_key and $requestData['votes_' . $next_votes_key] are string values and they are 
assigned to name and value fields of Setting.
My app/Settings.php model is very simple and have only 2 fillable fields name and value:

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

Thank you for your feedback! As I am new in AWS, could you please explain what is "hosted zone in Route 53" Is it service available with my free account?

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

I cleared log files and restarted php and nginx

running

curl http://demo1.myaccount-apps.tk/ 

at server's console I got :

...
...
    <body class="antialiased font-sans">
        <div class="md:flex min-h-screen">
            <div class="w-full md:w-1/2 bg-white flex items-center justify-center">
                <div class="max-w-sm m-8">
                    <div class="text-black text-5xl md:text-15xl font-black">
                        404                    </div>

                    <div class="w-16 h-1 bg-purple-light my-3 md:my-6"></div>

                    <p class="text-grey-darker text-2xl md:text-3xl font-light mb-8 leading-normal">
                        Sorry, the page you are looking for could not be found.                    </p>

                    <a href="http://demo1.myaccount-apps.tk">
                        <button class="bg-transparent text-grey-darkest font-bold uppercase tracking-wide py-3 px-6 border-2 border-grey-light hover:border-grey rounded-lg">
                            Go Home
                        </button>
                    </a>
                </div>
            </div>

            <div class="relative pb-full md:flex md:pb-0 md:min-h-screen w-full md:w-1/2">
                <div style="background-image: url(http://demo1.myaccount-apps.tk/svg/404.svg);" class="absolute pin bg-cover bg-no-repeat md:bg-left lg:bg-center">
</div>
            </div>
        </div>
    </body>
...
...

404 error ruuning demo1.myaccount-apps.tk at browser.

Files /var/log/nginx/access.log and /var/log/nginx/error.log are empty File /var/log/php7.2-fpm.log has:

20-Mar-2019 04:30:05] NOTICE: Terminating ...
[20-Mar-2019 04:30:05] NOTICE: exiting, bye-bye!
[20-Mar-2019 04:30:05] NOTICE: fpm is running, pid 4304
[20-Mar-2019 04:30:05] NOTICE: ready to handle connections
[20-Mar-2019 04:30:05] NOTICE: systemd monitor interval set to 10000ms

Any ideas ?

19 Mar
2 months ago

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

Searching in net I found hint to edit in /etc/hosts new line

ec2-NN-NN-NN-NN.us-east-2.compute.amazonaws.com   demo1.myaccount-apps.tk;

where demo1.myaccount-apps.tk - my domain created at freenom and ec2-NN-NN-NN-NN.us-east-2.compute.amazonaws.com - my aws account, I got "Welcome to nginx!" greeting page by it

and in /etc/nginx/sites-available/votes.com defined:

server_name demo1.myaccount-apps.tk;

but that did not help...

mstdmstd left a reply on How To Set Multiple Domain Names On 1 Nginx Server ?

On my local server in my /etc/hosts I have a line :

127.0.0.3       local-tasks.com

as I use appache with several my php apps. How to resalve this issue ?

mstdmstd started a new conversation How To Set Multiple Domain Names On 1 Nginx Server ?

Hello, I installed nginx under new ubuntu 18 installation under AWS and I want to make multiple domain names on 1 server. Fot this

  1. I created at freenom new hosting
demo1.myaccount-apps.tk
and with whatsmydns service I check that it is resolved ok:
https://www.whatsmydns.net/#CNAME/demo1.myaccount-apps.tk
  1. I installed nginx with "Welcome to nginx!" greeting page by
http://ec2-NN-NN-NN-NN.us-east-2.compute.amazonaws.com/

url

  1. Created /var/www/votes.com/index.php file with text
File <b>/var/www/votes.com/index.php </b> index
<?php
echo ‘Hello all!’;
phpinfo();
?>
  1. I created file /etc/nginx/sites-available/votes.com with text:
pstream votes-backend { # Lets you define a group of servers
   server unix:/var/run/php7.2-fpm.sock;
}

server {
   listen 80;

   root /var/www/votes.com;
   index index.php;

   server_name demo1.myaccount-apps.tk;


   # We keep this block, because it doesn't make sense to pass
   # everything to PHP.
   location / {
      # try_files $uri $uri/ =404;
      try_files $uri $uri/ /index.php index.php;

   }

   location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$; # this defines a regular expression to separate the SCRIPT_FILENAME and PATH_INFO for later use
     try_files $uri =404; # OR Set cgi.fix_pathinfo=0 in php.ini (for security)
     fastcgi_pass votes-backend; # OR unix:/var/run/php7.2-fpm.sock OR 127.0.0.1:9000
     fastcgi_index index.php; # appends index.php to a URI ending with a slash
     include fastcgi_params;
   }

}
  1. editied /etc/hosts (I am not sure if i have to edit it):
127.0.0.1 localhost
127.0.0.2   localhost test.com
127.0.0.3   demo1.myaccount-apps.tk
  1. created symbol link :
sudo ln -s /etc/nginx/sites-available/votes.com /etc/nginx/sites-enabled/
  1. restart nginx service and php:
sudo service nginx restart
sudo systemctl restart php7.2-fpm
  1. Check The Syntax Of nginx Files
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
  1. check that /etc/nginx/nginx.conf has links to /etc/nginx/sites-enabled/:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ...
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}
  1. but running http://demo1.myaccount-apps.tk/ in browser I got 404 error also running
curl http://demo1.myaccount-apps.tk/

in console of my server I got empty line, but I expected content of my /var/www/votes.com/index.php file?

What is wrong and how to fix it ?

Thanks!

03 Mar
2 months ago

mstdmstd left a reply on Why Error Subscribing To Specific Mailchimp List

Sorry, I still search for decision. Do you use laravel-newsletter plugin? Or do you use some other tools ?

01 Mar
2 months ago

mstdmstd started a new conversation Why Error Subscribing To Specific Mailchimp List

Hello, In my laravel 5.7 app I make subscribe/unsubscribe to lists of mailchimp using https://github.com/spatie/laravel-newsletter It works when ok and all users are suscribed to the current mailchimp list, which is described in .env file

MAILCHIMP_APIKEY = NNNNNNNNNN
MAILCHIMP_LIST_ID = NNNNNNNNNN  # ID of 'subscribers' mailchimp list

But as my site has several group news I try subscribe to mailchimp list with code :

$retData= Newsletter::subscribe($userProfile->email, ['FNAME'=>$userProfile->first_name, 'LNAME'=>$userProfile->last_name], 'subscribers'); // 3rd parameter can be different

where 3rd parameter is mailchimp list name, as I see it on the server as : https://prnt.sc/mqbgnb But I got error :

There is no list named `subscribers`.

Why error? Misconfiguring of of this mailchimp list ? It has some options, I am not sure if some of them is related to my issue ?

In doc I read as :

//Subscribe someone to a specific list by using the third argument:
Newsletter::subscribe('[email protected]', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');

How to fix my error ?

Thanks!

23 Feb
2 months ago

mstdmstd left a reply on I Have Some Problems Using Maatwebsite/excel

Also I did not find which is valid way of loading data with maatwebsite/excel plugin ?

mstdmstd left a reply on I Have Some Problems Using Maatwebsite/excel

@VNVDV91 - I searched that your example is based on https://github.com/Maatwebsite/Laravel-Excel-Light , which is not supported anymore. Seems bad idea... Any better decision?

mstdmstd left a reply on I Have Some Problems Using Maatwebsite/excel

Do you mean to use this plugin only for data reading and to make the rest functionality on myself ?

mstdmstd started a new conversation I Have Some Problems Using Maatwebsite/excel

Hi, Using in my laravel 5.7 app "maatwebsite/excel": "^3.1", I import csv file with line :

"Mr. John Smith", "3256 Epiphenomenal Avenue, Minneapolis, MN, 55416", "lead value", SS, "box client 1", Individual, "po box # 1", "office fax 123", "[email protected];[email protected];[email protected]", "1234-0987-0986;6543-098-1234","2018-07-18 12:25:29", "2018-07-18 12:25:29"

I managed to add a new client row, with method like :

<?php

class ClientsImport implements ToModel
{
    public function model(array $row)
    {
//        if (empty($row[0]) or empty($row[1]) ) return false;

        ...
        $emails                =  $row[8];
        $emailsArray           = $this->pregSplit('/;/',$emails);
        foreach( $emailsArray as $next_email ) {
            ...
        }

        $phones                =  $row[9];
        return new Client([
            'full_name'        =>  $row[0],
            'address'          =>  $row[1],
            'type'             =>  $row[2],
            'customer_type'    =>  $row[3],
            'box_client_id'    =>  $row[4],
            'account_type'     =>  $row[5],
            'po_box'           =>  $row[6],
            'office_fax'       =>  $row[7],
            'created_at'       =>  $row[10],
            'updated_at'        =>  $row[11],
        ]);
    }

    public function batchSize(): int
    {
        return 100;
    }

    public function chunkSize(): int
    {
        return 100;
    }
}

but I encountered some problems :

  1. As any client has several emails I need to them to related table. I can not do this in this method with emailsArray circle, as I have no client_id of new client(It is not added yet). If there is a way to make it?
  1. My csv files are not of high quality and it can have empty rows and required fields empty I tried to add line like:
        if (empty($row[0]) or empty($row[1]) ) return false;

But got error:

Argument 1 passed to Maatwebsite\Excel\Imports\ModelManager::Maatwebsite\Excel\Imports\{closure}() must be an instance of Illuminate\Database\Eloquent\Model, boolean given, called in /mnt/_work_sdb8/wwwroot/lar/BoxBooking2/vendor/laravel/framework/src/Illuminate/Support/Collection.php on line 418

If there is a way to skip such row? I found SkipsFailures trait, but I did not find if and how it can be used here?

  1. At the end import routing I got error:
The Response content must be a string or object implementing __toString(), "object" given.

but all rows were inserted successfully... Why error and how to fix it?

Thanks!

08 Feb
3 months ago

mstdmstd left a reply on Proengsoft/laravel-jsvalidation Failed Working With Using Harvesthq/chosen Library?

Thank youi for your feedback! In the layout of my app resources/views/Backend/layouts/backend.blade.php I added no conflict declaraions just after I included jquery:

    ...
    <script src="{{ asset('js/jquery-3.3.1.min.js') }}"></script>

    <script>
        jQuery.noConflict();
    </script>

    <script src="{{ asset('js/moment.min.js') }}"></script>

    <script src="{{ asset('/js/bootstrap.js') }}"></script>

    <script src="{{ asset('/js/jquery.bootstrap-growl.min.js') }}"></script>
    <script src="{{ asset('/js/jquery-confirm.min.js') }}"></script>
    <script src="{{ asset('js/chosen.jquery.js') }}"></script>

    <script src="{{ asset('js/app/app_funcs.js') }}{{  "?dt=".time()  }}"></script>

</head>

But after that I got error refering my jsvalidation library:

jsvalidation.js? [sm]:241 Uncaught TypeError: $ is not a function
    at jsvalidation.js? [sm]:241

and in browser's console I can see error pointing at my code : https://imgur.com/a/Hc8UJQD Which steps have I to take to fix all errors?

It seems to me that with noConflict option I have to replace all instruction substring "$(" with “jQuery(” ? Is it so ?

noConflict option is behind my expierence...

mstdmstd started a new conversation Https://stackoverflow.com/questions/54554774/proengsoft-laravel-jsvalidation-failed-working-with-using-harvesthq-chosen-libra

Hello In my laravel 5.7/ blade / jQuery v3.3.1 / Bootstrap v4.1.2 app I use https://github.com/proengsoft/laravel-jsvalidation library, with definition in my blade form

    <script src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
    {!! JsValidator::formRequest('App\Http\Requests\StorageSpaceRequest', '#form_storage_space_edit'); !!}

where StorageSpaceRequest is file in app/Http/Requests subdirectory, It works ok , until I decided to replace select inputs with https://harvesthq.github.io/chosen/ library and my validation rules(usually required) do not work any more.

I init chosen with code

    $(".chosen_select_box").chosen({
        disable_search_threshold: 10,
        no_results_text: "Nothing found!",
    });

Before replacement this good working select input looked like:

<div class="col-xs-12 col-sm-8">
        <select class="form-control editable_field" id="customer_type" name="customer_type" data-placeholder="Choose customer type" aria-describedby="customer_type-error" aria-invalid="true"><option value="" selected=""></option><option value="SS">SS</option><option value="RS">RS</option></select><span id="customer_type-error" class="help-block error-help-block">The customer type field is required.</span>
    </div>
    
After replacement with chosen selector(which do not work) has syntax:
<select class="form-control editable_field chosen_select_box" id="account_type" name="account_type" data-placeholder="Choose account type" style="display: none;"><option value="" selected=""></option><option value="I">Individual</option><option value="B">Business</option></select>   

I suppose that the reason of this error is that when value in chosen selection is selectted, its value is not saved in

 id="account_type" name="account_type"...

I tried a decision to set near with chosen input hidden input and in chosen input to modify id and set onchange event in my select wrapper, like :

{!! $viewFuncs->select('chosen_storage_type_id', $storageTypesArray, isset($storageSpace->storage_type_id) ? $storageSpace->storage_type_id : '', "form-control
 editable_field chosen_select_box", ['onchange'=>"javascript:chosenSelectionOnChange('storage_type_id'); ",'data-placeholder'=>"Choose storage type"] ) !!}
<input type="hidden" id="storage_type_id" name="storage_type_id" value="{{ isset($storageSpace->storage_type_id) ? $storageSpace->storage_type_id : '' }}">

so in chosenSelectionOnChange new value is set to hidden input, but looks like laravel-jsvalidation can not work with hidden inputs... Can be some other decision ?

can it be fixed somehow? I got chosen selection as it has search functionality and seems good working...

Thanks!

07 Feb
3 months ago

mstdmstd started a new conversation Submitting The Form To Show Old Empty Value In Validation Error

Hello In my laravel 5.7/ blade app in my form I make next condition for value property of an text input :

value=" ( !empty(old('field_name')) ? old('field_name') : ( isset($dbRow) ?$dbRow->field_name : '') ) "

but it does not work as I expected : if having entered field value user clear this value and submit the form then oroginal value $dbRow->field_name is show, but not last entered empty value. I need in my blade some key that it is invalid form submittion? Has laravel any? Or some other decision ?

Thanks!

03 Feb
3 months ago

mstdmstd left a reply on Working With Table Prefix In Join Request

Thank you for feedback! Actually I did not know about getTable method. But that is not the issue. Problem is that I have problems when making request with joining table in I have prefixed tables. I gave an example at start of my topic.

Could you please give some examples how looks like similar requests in your apps? When several tables are joined with aliases of tables?

02 Feb
3 months ago

mstdmstd started a new conversation Working With Table Prefix In Join Request

Hello, In my laravel 5.7 app I work with mysql with prefix option filled in config/database.php It seems somewhat complicated when I work with several tables. I make it as :

$votes_tb= with(new Vote)->getTableName() ;
$vote_category_tb= with(new VoteCategory)->getTableName();
$votesCollection = Vote::
leftJoin(  $vote_category_tb . ' as vc ', 'vc.id', '=', $votes_tb . '.vote_category_id')
->select( $votes_tb.".*, vc.name as vote_category_name")
->get();

and I got error :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vt_votes.*, vc.name' in 'field list' (SQL: select `vt_votes`.`*, vc`.`name` as `vote_category_name` from `vt_votes` left join `vt_vote_categories` as `vt_vc ` on `vt_vc`.`id` = `vt_votes`.`vote_category_id`)

Looks like that concatenated string in select method was calculated as 1 column?

I tried to wrap select method in raw function,

->select( \DB::raw($votes_tb.".*, vc.name as vote_category_name"))

but got error:

SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'votes' (SQL: select votes.*, vc.name as vote_category_name from `vt_votes` left join `vt_vote_categories` as `vt_vc ` on `vt_vc`.`id` = `vt_votes`.`vote_category_id`)

Vote and VoteCategory models have definition in itself like:

protected $table = 'votes';
...
public function getTableName() : string
{
    return $this->table;
}

and

protected $table = 'vote_categories';
...
public function getTableName() : string
{
    return $this->table;
}

Can you advice some proper way ?

Thanks!

01 Feb
3 months ago

mstdmstd started a new conversation Why Doubled Name In Route Name ?

Hello, In my laravel 5.7 app in routes/web.php I have definitions :

Route::group(['middleware' => ['auth'], 'prefix' => 'admin', 'as' => 'admin.'], function () {
...
    Route::resource('departments', 'Admin\DepartmentsController', [ 'as' => 'departments', 'except' => [] ] )->middleware('WorkTextString');
    Route::get( 'get-departments-dt-listing', [ 'uses' => 'Admin\[email protected]_departments_dt_listing' ] );

Running command

php artisan route:list

I see : index is defined with name admin.departments.departments.index :

|        | GET|HEAD  | admin/departments                                    | admin.departments.departments.index                   | App\Http\Controllers\Admin\[email protected]                                     | web,auth,WorkTextString |

and this name I have to use calling redirect()->route( method.

Why I have 2 departments. in name and how to remove 1 of it?

Thanks!

30 Jan
3 months ago

mstdmstd left a reply on About Payment On Cloud.digitalocean.com

Yes, on support page I found how to create a ticket and twice last days I sent new tickets and after that my databases were not deleted anymore. But in feedback emails from Digital Ocean there were answers to my questions - they were too common... This situation is annoying and surprizing. I think last year I did not have some problems if I did not pay for 2-3 weeks.

  1. Did some rules were changed and I miss?

  2. If there is a way in beginning of the month to pay till the end of the current month?

26 Jan
3 months ago

mstdmstd left a reply on I Got Error Setting ->change Method In Miigration

I still search for a decision. Searching in net I found using of ->default( in migration, but trying to make like:

            $table->timestamp('created_at')->default( `CURRENT_TIMESTAMP`)->change();

I got message :

sh: 1: CURRENT_TIMESTAMP: not found

and no modifications in db

I tried to make like

            $table->timestamp('created_at')->default( "`CURRENT_TIMESTAMP`")->change();

I got syntax error, like :

ALTER TABLE warehouses CHANGE created_at created_at TIMESTAMP NULL DEFAULT 'CURRENT_TIMESTAMP';

as CURRENT_TIMESTAMP must be without any brackets. Which is the valid way?

23 Jan
3 months ago

mstdmstd left a reply on About Payment On Cloud.digitalocean.com

and again my demo database was deleted and I do not know how to get in touch with supoort ofthem. Have they some ?

Where is support page under https://cloud.digitalocean.com ?

Does anybody have similar problems with digitalocean.com ?