Gabotronix

Gabotronix

Member Since 1 Year Ago

Experience Points 21,170
Experience Level 5

3,830 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 45
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.

16 Jun
1 day ago

Gabotronix started a new conversation Laravel Apps, DigitalOcean And CPU/RAM Usage

Hi everybody, I currently have a DigitalOcean VPS with 1GB and v3CPU, my apps run fine with this but I'm thinking about upgrading to the 20 dllars/month plan, however something caught my attention, the 20month plan has 3GB more of RAM but one less of CPU, this seems pretty weird to me to be honest, I don't know if laravel apps are more CPU heavy than RAM so I'm looking for some advice, I doon't want to shoot myself in the foot by upgrading to a plan which could negatively affect the performance of my apps, my webs are all middel-sized laravel apps.

Can someone shed some light on me?

Gabotronix left a reply on Running Out Of Memory Trying To Install Envoy Globally On Production Server

@DEANSATCH - What ubuntu commands would help me identify proccesses which are taking lots of memory= and to kil them? sorry for noob question.

15 Jun
2 days ago

Gabotronix started a new conversation Running Out Of Memory Trying To Install Envoy Globally On Production Server

Hi everybody, I have a DigitalOcean VPS I pay 15 bucks monthly for, I'm trying to install laravel envoy task runner with this command:

composer global require laravel/envoy

But I get the following error:


mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 459276288) (tried to allocate 2131644 bytes) in /usr/share/php/Composer/Util/RemoteFilesystem.php on line 419

Fatal error: Out of memory (allocated 459276288) (tried to allocate 2131644 bytes) in /usr/share/php/Composer/Util/RemoteFilesystem.php on line 419

Any ideas ?

14 Jun
3 days ago

Gabotronix started a new conversation User Deploy Is Currently Used By Process 10210 In Ubuntu VPS

Hi everybody, I'm trying to set the home directory for a deploy user I changed the name using usermod -d /home/user user command, however I'm getting the following error message:

user deploy is currently used by process 10210

Command it's not taking effect, I'm still a noob with ubutu so please help me out.

13 Jun
4 days ago

Gabotronix started a new conversation Envoy, Putty, SSH Keys And Connecting To Ubuntu VPS

Hi everybody, I recently started to read about envoy, a suitable way to deploy my apps with a single command, it uses blade syntax too so it's a win-win, however there's an issue, I have been coonecting to my VPS with Putty and using a really hard to guess password (afaik a brute force attack would break my barrier), I have also read about SSH key pairs and honestly I'm a bit scared if I the private key file I'd get locked out of my server.

So I have a few questions:

-Once I create my SSH key pair, if I save these files into say Google Drive or similar, if I lose my laptop or gets stolen will I still be able to access my servers with the backup key files from my google drive accound?

-Would it be possible to run envoy run deploy command if have password auth instead f SSH keys? I haven't tried yet but maybe it'll ask me for my sudo password for a few commands (sudo, git) but that doesn't sound too bad honestly...

Thanks in advance.

09 Jun
1 week ago

Gabotronix left a reply on Can't Set Background Image With Vue

Issue was with spacs in the image name, it's solved now

Gabotronix left a reply on Can't Center Div Inside Slick-slider Item With Flex

@AURAWINDSURFING - I don't use tailwind css (never used a css framework before), I fixed this by using display:flex !important...

Gabotronix started a new conversation Vue: Issue With Reactive Object Not Updating?

Hi everybody, I have an item card component I set with an v-for, inside each component you can increase or decrease the number of items the user want to add to the cart, when I click I get an alert and the count increases/decreases as it should but the value disocnt.quantity doesn't update in mu view, it's always 1 (default value).

I know about reactivity caveats and I'm using Vue.set to make the property reactive but it's not updating... check my component:

<template>
<div class="DISCOUNTlist6_item_container shadow">
    <div class="DISCOUNTlist6_item_texts_container">
        <span class="DISCOUNTlist6_item_texts_title fs_bigger c_light">
                {{ discount.title }}
                <span class="DISCOUNTlist6_item_texts_title_deco"></span>
        </span>
        <div class="DISCOUNTlist6_item_texts_price_container">
                <span class="DISCOUNTlist6_item_texts_price_text fs_normal c_light">llevatelo por solo</span>
                <span class="DISCOUNTlist6_item_texts_price_value fs_huge main">{{ discount.finalPrice }} €</span>
        </div>
        <div class="DISCOUNTlist6_item_texts_quantity_container" style="width:100%; height:auto; display:flex;  justify-content:space-between; flex-wrap:no-wrap; margin:20px 0px 0px 0px;">
            <div class="DISCOUNTlist6_item_texts_quantity_row_container" style="width:35%; height:40px; display:flex;">
                <button class="DISCOUNTlist6_item_texts_quantity_button" @click="decreaseQuantityByOne()" style="width:40px; height:40px; display:flex; align-items:center; justify-content:center; background-color:rgb(10,10,10);" type="button"><i class="fa fa-minus fs_smaller c_light"></i></button>
                <div class="DISCOUNTlist6_item_texts_quantity_number fs_big c_normal" style="flex:1; height:100%; display:flex; align-items:center; background-color:white; justify-content:center;">{{ discount.quantity }}</div>
                <button class="DISCOUNTlist6_item_texts_quantity_button" @click="increaseQuantityByOne()" style="width:40px; height:40px; display:flex; align-items:center; justify-content:center; background-color:rgb(10,10,10);" type="button"><i class="fa fa-plus fs_smaller c_light"></i></button>
            </div>
            <button class="DISCOUNTlist6_item_texts_quantity_cart_button secondary fs_big" @click="getDiscountData()" :disabled="!globals.auth" style="width:62%; height:40px; background-color:var(--web_primary_color);">Añadir al carrito</button>
        </div>
    </div>
</div>
</template>
<!--SCRIPTS-->
<script>
import { mapState, mapActions, mapMutations } from 'vuex';
import { printScore } from '../../includes/reviews.js';
export default {
name: 'DISCOUNTcard5',


computed:
{
    ...mapState('Globals',['globals'])
},


props:
{
    discount: {required:true},
},


mounted()
{
    console.log(this.$options.name+' component successfully mounted');
},


methods:
{
  

    ...mapActions('Cart', ['addProductToCart']),


   

    decreaseQuantityByOne: function()
    {
        if(this.discount.quantity > 1){
            this.discount.quantity = this.discount.quantity - 1;
        }
    },


    increaseQuantityByOne: function()
    {
        if(this.discount.quantity < this.discount.stock_left){
            //this.discount.quantity = this.discount.quantity + 1;
            //Vue.set(this.discount, 'quantity', this.discount.quantity + 1)
            this.$set(this.discount, 'quantity',  this.discount.quantity + 1)
            alert(this.discount.quantity);
        }
    },
}


};
</script>
07 Jun
1 week ago

Gabotronix left a reply on Automating Tasks With Commands In Ubuntu Enviroment

I'm also reading about laravel artisan commands, they look reay handy for mysql operations like creating/deleting a database, is this good practice? loging and exiting mysql from the command to do some ops gets a little boring

06 Jun
1 week ago

Gabotronix left a reply on Prevent Event Propagation In Vue

@HAMZAKHCHICHINE - Thanks, so maybe prevent is to stop the event from going down the DOM tree and stop from going up?

Gabotronix started a new conversation Question About Php Proccesses In Linux VPS

Hi everybody, I have a DigitalOcean VPS with ubuntu where I'm running various laravel apps, I recently updated PHP to 7.3, I did this by tweaking my nginx server block files to use the 7.3 fpm socket, now I learn of the ps command that shows procceses running in my linux machine, I decided to do a ps aux | grep php and this shows the following screen:

https://i.imgur.com/ZLSXE9k.png

Well, I'm a noob with ps command but I can clearly see three php procceses running right? one for 7.3 and two of older versions, now this let me wondering if these lower than 7.3 procceses are cluttering my linux machine with unneeded overhead...

Someone shed some light on me please.

Also do you gius know of any good starting point for learning linux server management, I want to know about useful commands like this one.

Gabotronix started a new conversation Prevent Event Propagation In Vue

Hi everybody, I have a list of available cards for online payments with stripe, there I have a button with an icon inisde, if you click the button or the icon both fire different method, however when the icon is clicked (icon is inside the button), the button method also fires, I want to avoid this but so far havne't find a way.

<button class="STRIPElist2_cardlist_container" @click.stop="setDefaultSource({ id: source.id }); SET_LOADER_ID(7563);" :class="{ 'active_card' : customerDefaultSource == source.id }" type="button" v-for="(source, index) in customerSources" :key="index">
            <div class="STRIPElist2_cardlist_radio_container">
                <div class="STRIPElist2_cardlist_radio_inner" :class="{ 'active_radio' : customerDefaultSource == source.id }"></div>
            </div>
            <span class="STRIPElist2_cardlist_text fs_normal c_normal four">✱✱✱✱ ✱✱✱✱ ✱✱✱✱ {{ source.card.last4 }}</span>
            <span class="STRIPElist2_cardlist_text fs_normal c_normal brand">{{ source.card.brand }}</span>
            <span class="STRIPElist2_cardlist_text fs_normal c_normal exp">{{ source.card.exp_month }} / {{ source.card.exp_year }}</span>
            <i class="STRIPElist2_cardlist_close fa fa-times fs_big c_normal" @click.prevent.self="deleteSource({ id: source.id }); SET_LOADER_ID(7563);"></i>
        </button>
30 May
2 weeks ago

Gabotronix started a new conversation Issue With HasManyThrough Relationship

Hi everybody, I created four models: Item, ItemOption, ItemSize, ItemColor. I set these models with a hasManyThrough relationship but then I get this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'item_colors.item_option_id' in 'on clause' (SQL: select `item_colors`.*, `item_options`.`item_id` as `laravel_through_key` from `item_colors` inner join `item_options` on `item_options`.`id` = `item_colors`.`item_option_id` where `item_options`.`item_id` in (1))

These are my migrations:

Schema::create('item_options', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('item_id')->index()->nullable();
            $table->foreign('item_id')->references('id')->on('items')->nullable();
            $table->unsignedInteger('item_size_id')->index()->nullable();
            $table->foreign('item_size_id')->references('id')->on('item_sizes')->nullable();
            $table->unsignedInteger('item_color_id')->index()->nullable();
            $table->foreign('item_color_id')->references('id')->on('item_colors')->nullable();
            $table->timestamps();
        });


Schema::create('items', function (Blueprint $table) {
            $table->increments('id');
            $table->string('image')->nullable();
            $table->string('title');
            $table->decimal('finalPrice', 5,2);
            $table->text('body');
            $table->timestamps();
        });

Schema::create('item_colors', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('colorCode');
            $table->timestamps();
        });

Schema::create('item_sizes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->timestamps();
        });

And my models:

class Item extends Model
{
    
    
    protected $table = 'items';
    
    
    public function options()
    {
        return $this->hasMany(ItemOption::class);
    }

    public function sizes()
    {
        return $this->hasManyThrough(ItemSize::class, ItemOption::class);
    }

    public function colors()
    {
        return $this->hasManyThrough(ItemColor::class, ItemOption::class);
    }

    
}


class ItemOption extends Model
{
    
    protected $fillable = ['item_id', 'item_color_id', 'item_size_id', 'stock'];

    public function color()
    {
        return $this->belongsTo(ItemColor::class);
    }

    public function size()
    {
        return $this->belongsTo(ItemSize::class);
    }

    
}
29 May
2 weeks ago

Gabotronix started a new conversation Can't Center Div Inside Slick-slider Item With Flex

Hi everybody, I made a slick slider component in vue, I'm trying to center a circular div inside each one of the slider items but I can't get tit to work, it centers horizontally after I added margin:auto but it doesn't center vertically despite using align and justify center, any idea how I can get this to work? I think it has something to do with how slick slider changes the width of the slick items via javascript...

<template>
<slick class="SLIDERcontainer6_maincontainer" ref="slick" :options="slickOptions">
    <div class="SLIDERcontainer6_item_container" v-for="slider in globals.producsSlider" :key="slider.title">
        <div class="SLIDERcontainer6_item_image" :style="'background-image:url('+slider.image+');'"></div>
    </div>
</slick>
</template>
<!--SCRIPTS-->
<script>
import { mapState } from 'vuex';
import Slick from 'vue-slick';
export default {
name: 'SLIDERcontainer10',


components: { Slick },


computed:
{
    ...mapState('Globals',['globals'])
},


data()
{
    return {
        slickOptions: {
        infinite: true,
        slidesToShow: 4,
        slidesToScroll: 1,
        prevArrow: '<i class="fa fa-chevron-left fs_bigger c_light" style="position:absolute; left:10px; top:50%; transform:translateY(-50%); z-index:99999;"></i>',
        nextArrow: '<i class="fa fa-chevron-right fs_bigger c_light" style="position:absolute; right:10px; top:50%; transform:translateY(-50%); z-index:99999;"></i>',
        arrows: true,
        autoplay: true,
        speed: 2000,
        autoplaySpeed: 4000,
        responsive: 
        [
        {
        breakpoint: 1120,
            settings: 
            {   
            slidesToShow: 3,
            slidesToScroll: 1,
            }
        },
        {
            breakpoint: 800,
            settings: 
            {
            slidesToShow: 2,
            slidesToScroll: 2
            }
        },
        {
            breakpoint: 600,
            settings: 
            {
            slidesToShow: 1,
            slidesToScroll: 1
            }
        }]
        },

    };
},


beforeUpdate()
{
    if (this.$refs.slick) {
        this.$refs.slick.destroy();
    }
},


updated()
{
    this.$nextTick(function () {
        if (this.$refs.slick) {
            this.$refs.slick.create(this.slickOptions);
        }
    });
},


mounted()
{
    console.log(this.$options.name+' component successfully mounted');

},


};
</script>
<!--STYLES-->
<style scoped>
.SLIDERcontainer6_maincontainer{width:100%; height:auto; position:relative;}
.SLIDERcontainer6_item_container{width:33.33%; height:350px; display:flex; flex-direction:column; align-items:center; justify-content:center; background-color:var(--web_primary_color); position:relative;}
.SLIDERcontainer6_item_image{width:275px; height:275px; border-radius:50%; background-size:cover; background-position:center; margin:auto; align-self:center;}
@media only screen and (max-width: 736px) 
{
}
</style>

27 May
3 weeks ago

Gabotronix started a new conversation Help With Shop Items Many To Many Relationship

Hi everybody, I'm working on an e-commerce web where you can buy some items, say shirts... I have three models Item, ItemColor and ItemSize. I have set up a many to many relationship where an item in the shop can have many colors and many sizes available but each of these items will have a stock on it's own, here is where things get complicated for me.

If I create an item, for example a shirt X, I can attach to that shirt different colors and sizes availabale (many to many) but how can I set up so each type of shirt has a stock?? I'm failing to see this in a clear way...

Where should I put stock attribute? in pivot table maybe?

Here are my models and migrations:

//item model
protected $table = 'items';
    
    
    public function colors()
    {
        return $this->belongsToMany('App\Models\ItemColor');
    }

    public function sizes()
    {
        return $this->belongsToMany('App\Models\ItemSize');
    }

//tiemsize model

protected $table = 'item_sizes';
    
    
    public function items()
    {
        return $this->belongsToMany('App\Models\Item');
    }

//item colors

protected $table = 'item_colors';
    
    
    public function items()
    {
        return $this->belongsToMany('App\Models\Item');
    }

And migrations


//pivot table
Schema::create('item_size_color', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('item_id')->index();
            $table->foreign('item_id')->references('id')->on('items');
            $table->unsignedInteger('item_size_id')->index();
            $table->foreign('item_size_id')->references('id')->on('item_sizes');
            $table->unsignedInteger('item_color_id')->index();
            $table->foreign('item_color_id')->references('id')->on('item_sizes');
            $table->timestamps();
        });

//items table
Schema::create('items', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->timestamps();
        });

//items color table
Schema::create('item_colors', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->timestamps();
        });

//items size table
Schema::create('item_sizes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->timestamps();
        });
26 May
3 weeks ago

Gabotronix started a new conversation Error When Running Npm Run Prod In Production

Hi everybody, I'm experiencing same error over and over again when I run npm run prod in my VPS, no issue with my local dev machine:

This is the error:


$ npm run prod

> @ prod /var/www/dtcburger.es
> npm run production


> @ production /var/www/dtcburger.es
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn ENOMEM
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:508:9)
    at Object.exports.fork (child_process.js:109:10)
    at fork (/var/www/dtcburger.es/node_modules/worker-farm/lib/fork.js:17:36)
    at Farm.startChild (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:106:16)
    at Farm.processQueue (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:279:10)
    at Farm.<anonymous> (/var/www/dtcburger.es/node_modules/worker-farm/lib/farm.js:97:21)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gabotron/.npm/_logs/2019-05-26T16_59_29_167Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gabotron/.npm/_logs/2019-05-26T16_59_29_200Z-debug.log

Gabotronix started a new conversation Running Npm Run Prod

Hi everybody, I have a few production apps in my DO VPS, I have laravel-mix versioning enabled but I have noticed the nly way for my css to be updated instead of showing the ld css design is to run npm run prod in my ubuntu server, I have a few questions regarding this:

-1) Why do I have to do npm run prod for my webs to show updated design instead of cached one (this is particulary stinky in mobile chrome).

-2) Is running npm run prd in prduction a good idea, I don't want to cause a mess.

I'm also a lon developer/learner so I don't work in a team, just in case.

25 May
3 weeks ago

Gabotronix started a new conversation Issue Creating Log Files With Nano And &&

Hi everybod, in my ubuntu VPS I'm trying to get three commands to run after each other using &&, what I do is create a folder and inside that folder I create two log files using nano, this however doesn't create the log files, only the mai folder, after running the bellow command it tells me file is not writtable and to save into buffer, so I just cancel the operation with no log files created... This are the commands:

sudo mkdir /var/log/peter.com && nano /var/log/peter.com/access.log && nano /var/log/peter.com/error.log

Gabotronix left a reply on Failed To Open Stream When Uploading File Via Ajax

Okk, after checking uploads folder perms inside public they were: rwx r-x --x, I did a chmod 770 to uploads and now everything works, what do you guys think, I hope I didn't do anything risky.

I want to show you guys the commands I now use fot setting perms so you can give me your thoughs:

cd /var/www/luisaldada.com
sudo chown GabotronES:ww-data /var/www/luisaldada.com
&&
find /var/www/luisaldada.com -type d -exec chmod 755 {} \;
&&
find /var/www/luisaldada.com -type f -exec chmod 644 {} \;
&&
chmod 770 /var/www/luisaldada.com/public/uploads
&&
setfacl -Rdm u:www-data:rwx,u:GabotronES:rwx storage bootstrap/cache
&&
setfacl -Rm u:www-data:rwx,u:GabotronES:rwx storage bootstrap/cache

Gabotronix started a new conversation Failed To Open Stream When Uploading File Via Ajax

Hi everybody, I have a laravel app in production DigitalOcean VPS, web works perfectly but it seems I can't upload files from my web, when I try to upload image via ajax I get the following error (only in production, local works right):

message fopen(/var/www/luisaldada.com/public/uploads/file-25-05-2019-21-39-MAL-421.jpeg): failed to open stream: Permission denied
exception   ErrorException
file    /var/www/luisaldada.com/vendor/league/flysystem/src/Adapter/Local.php
line    158

This looks like an obvious permission error but I already gave write perm recursively to laravel storage folder, I'm using laravel public/local disk to upload files into an upload folder inside public.

filesystems config file:

'public' => [
            'driver' => 'local',
            'root' => public_path(),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

Maybe it has something to do with public folder not having correct permissions to upload/write?

This are my permisions for laravel folder, as you can see I have gone as far as to set ACL for storage folder.

https://i.imgur.com/LLYIECc.png

This is how I upload file in contrller just in case:

$file = $request->file($name);
        $filename = 'file-'.Carbon::now()->format('d-m-Y-H-i').'-'.str_random(3).'-'.mt_rand('000','999').'.'.$file->extension();
        $file->storeAs('uploads', $filename);

Gabotronix left a reply on Question About Laravel And Nginx Logs

Okk that made things more clear, thanks guys!

Gabotronix started a new conversation Question About Laravel And Nginx Logs

Hi everybody, I have a noob question. On my lemp stacl I always define access and error log files for nginx in /var/log/appname folder and then in my nginx conf I have:

access_log /var/log/clunkertree.com/access.log;
    error_log /var/log/clunkertree.com/error.log;

I also know that laravel has laravel.log file in storage, in this file all errors such as 404, 500, Exceptions are logged, now I just checked my access.log file and it has many lines, all right but ALL my error logs are empty, this has led me to believe that I shouldn't really be creating a error.log file since it appears all laravel errors are logged into laravel.log file, onlu an access.log and laravel's default laravel.log file will suffice, am I mistaken??

Gabotronix started a new conversation Artisan Command To Create Nginx Log Files

Hi everybody, in my DigitalOcean VPS I have a lemp stack, I usually create access.log and error.log inside /var/log directory, now I just learnt of laravel artisan comands and I'm starting to read about them, I want to create an artisan command to automate some tasks, this is my first attempt and I want suggestions and advice, am I doing good with a try catch for error handling?

Basically I want this comand to create a folder and if successfull, create two log files for nginx web server:

<?php
namespace App\Console\Commands;


use Illuminate\Console\Command;
use Exception;


class CreateNginxLogs extends Command
{
    protected $description = 'This command creates access and error logs for nginx web server';
    protected $signature = 'log:create nginx';


    public function handle()
    {
        
        $path = '/var/log/'.config('app.domain');

        try
        {
            mkdir($path, 0775, true);

            fopen($path.'/access.log', 'w');

            fopen($path.'/error.log', 'w');
        }
        catch(Exception $e)
        {
            echo($this->error($e->getMessage()));
        }
          
    }

}

Will this even work?

Gabotronix started a new conversation Error When Restarting Nginx Service In Ubuntu

Hi everybody, I have a DigitalOcean VPS where I host some production apps, when I try to do sudo service nginx restat or systemctl restart nginx.service I get the following error:

https://i.imgur.com/zumXbeZ.png

I ran sudo nginx -t and conf and syntax are ok, wha twould be the problem?

My production apps also appear to work properly.

24 May
3 weeks ago

Gabotronix started a new conversation Automating Tasks With Commands In Ubuntu Enviroment

Hi everybody, prior to deploying my web projects I usually do some tasks like creating log folder and files for nginx , this usually involves running following commands:

mkdir /var/log/domain.com nano /var/log/domain.com/access.log nano /var/log/domain.com/error.log

No w I was wondering if I can run this three commands with a single command like:

create logs domain.com 

Gabotronix left a reply on Issue With Relationship

@SNAPEY - Okk I added fk to shirt migrations and the tables were created succesfully, but now when I create a shirt I get the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'shirt_sizes.shirt_id' in 'where clause' (SQL: select * from `shirt_sizes` where `shirt_sizes`.`shirt_id` in (3))

Gabotronix started a new conversation Issue With Relationship

Hi everbody, I' m trying to make a relationship with laravel, a shirt has one color and one size, colors and sizes can belong to many shirts, this are my migration files in detail:

Schema::create('shirts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('stock');
            $table->string('url')->unique();
            $table->string('slug')->unique();
            $table->string('title')->unique();
            $table->longText('body')->nullable();
            $table->string('image')->nullable();
            $table->boolean('isVisible')->default(false);
            $table->boolean('isFeatured')->default(false);
            $table->boolean('beenPublished')->default(false);
            $table->boolean('scheduleForMail')->default(false);
            $table->timestamps();
        });

Schema::create('shirt_colors', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('shirt_id')->index();
            $table->foreign('shirt_id')->references('id')->on('shirts');
            $table->string('title');
            $table->string('colorCode');
            $table->boolean('isVisible')->default(true);
            $table->timestamps();
        });

Schema::create('shirt_sizes', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('shirt_id')->index();
            $table->foreign('shirt_id')->references('id')->on('shirts');
            $table->string('title');
            $table->boolean('isVisible')->default(true);
            $table->timestamps();
        });

And my models:

//Shirt
protected $table = 'shirts';


    public function color()
    {
        return $this->hasOne('App\Models\ShirtColor');
    }


    public function size()
    {
        return $this->hasOne('App\Models\ShirtSize');
    }
//ShirtColor

protected $table = 'shirt_colors';


    public function shirts()
    {
        return $this->belongsToMany('App\Models\Shirt');
    }

//ShirtSize

 protected $table = 'shirt_sizes';


    public function shirts()
    {
        return $this->belongsToMany('App\Models\Shirt');
    }

Any idea what I'm doing wrong?

Gabotronix left a reply on Serve Multiple Laravel Apps On Localhost With Php Artisan Serve

I ran:

php artisan serve -port 8001

in my local dev lamp stack and it worked perfectly, I just wanted to see various web designs at once so it's all good, thanks everybody

23 May
3 weeks ago

Gabotronix started a new conversation Serve Multiple Laravel Apps On Localhost With Php Artisan Serve

Hi everybody, I'd like to be able to serve more than one laravel app at the same time on different tabs/ports, this is so I can showcase various designs, sadly when I run php artisan serve I can get only one app running at a time on port 8000.

Even after updating to laravel 5.8, form the docs:

Artisan Serve Improvements
In previous releases of Laravel, Artisan's serve command would serve your application on port  8000. If another serve command process was already listening on this port, an attempt to serve a second application via serve would fail. Beginning in Laravel 5.8, serve will now scan for available ports up to port 8009, allowing you to serve multiple applications at once.

Is there anything I'm missing?

Gabotronix started a new conversation Seeding/Creating Many-to-many Relationships

Hi everybody, I have tow models Winner and Competition, a winner may have won many competitions and a competition may have been won by many winners, this to me is a many-to-many relationship.

Now I created my two migrations and pivot table migration:

Schema::create('winners', function (Blueprint $table) {
            $table->increments('id'); 
            $table->string('instagram');
            $table->timestamps();
        });

Schema::create('competitions', function (Blueprint $table) {
            $table->increments('id'); 
            $table->string('name');
            $table->timestamps();
        });

Schema::create('winner_competition', function (Blueprint $table) {
            $table->integer('winner_id')->unsigned();
            $table->integer('competition_id')->unsigned();
            $table->foreign('winner_id')->references('id')->on('winners')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('competition_id')->references('id')->on('competitions')->onDelete('cascade')->onUpdate('cascade');
        });

Now I want to seed create a few winners but I don't know how I should assign a competition to a winner in seed file and controller method:

public function create(Create $request)
    {
        $winner = new Winner();
        $winner->instagram = $request->input('instagram');
        $winner->competition_id = '?';
        $winner->save();
        
        return response()->json([
            'winner' => $winner
        ]);
    }

DB::table('winners')->insert([
            'instagram' => '@hfgfgdhdd',
            'competition_id' => '?'
        ]);

Someone shed some light on me.

22 May
3 weeks ago

Gabotronix started a new conversation Can't Set Background Image With Vue

Hi everybody, I have a component where I display a list of post_categories, each post_category has an image attribute and I create these like:

DB::table('postcategories')->insert([
            'title' => 'Clases',
            'url' => '/publicaciones/clases',
            'slug' => 'clases',
            'image' => '/img/photos/dogs (20).jpg',
        ]);
        DB::table('postcategories')->insert([
            'title' => 'Problemas de conducta',
            'url' => '/publicaciones/problemas-de-conducta',
            'slug' => 'problemas-de-conducta',
            'image' => '/img/photos/dogs (21).jpg',
        ]);

The models get created right but when I want to set background image inside v-dor it doesn't work, however if instead of div with background-image I use an img tag with src it works, why can't I use background-image instead?

<template>
    <div class="POSTcard2_maincontainer shadow" :href="post.url">
        <div class="POSTcard2_image_container">
            <!--THIS DOESN'T WORK--><a class="POSTcard2_image" :style="'background-image:url('+post.image+');'"></a>
            <!--THIS WORKS--><img class="POSTcard2_image" v-if="post.image" :src="post.image">
            <div class="POSTcard2_title_container">
                <span class="POSTcard2_title_text c_normal bold c_light">{{ post.title }}</span>
                <div class="POSTcard2_title_button">
                    <i class="POSTcard2_title_button_icon fa fa-chevron-right fs_big c_light" ></i>
                </div>
            </div>
        </div>
    </div>
</template>
21 May
3 weeks ago

Gabotronix started a new conversation Help With Shirt -> Colors -> Sizes Relationship

Hi everybody, I'm trying to wrap my head about this relationship which I think is many-to-many, I have 3 models, a shirt model, a shirt color model and a shirtsize model. Now this is how I see things, I could say:

One shirt can be many colors and many sizes but you could also say a shirt will be ONE color and ONE size (a shirt can't be multiple colors/sizes at once...) , so this got me pretty confused. I got the feeling this has to be a many to many relationship between shirt, size and color but I'm not so sure how (and if I should) do this?

This are my migrations:

Schema::create('shirts', function (Blueprint $table) {
            $table->increments('id');
            $table->string('slug')->unique();
            $table->string('url')->unique();
            $table->string('title')->unique();
            $table->longText('body');
            $table->decimal('finalPrice', 5,2);
            $table->integer('totalCount');
            $table->string('image')->nullable();
            $table->boolean('isVisible')->default(false);
            $table->boolean('beenPublished')->default(false);
            $table->boolean('scheduleForMail')->default(false);
            $table->timestamps();
        });


Schema::create('shirtcolors', function (Blueprint $table) {
            $table->increments('id'); 
            $table->string('title');
            $table->string('hexColor');
            $table->timestamps();
        });



Schema::create('shirtsizes', function (Blueprint $table) {
            $table->increments('id'); 
            $table->string('title')->nullable();
            $table->timestamps();
        });

Gabotronix left a reply on Merging Two Collections Only Returns One

@JLRDW - I want to merge both arrays into one but I only get an array with posts, I want ONE array with posts AND events, for some reason merge is not working.

Gabotronix started a new conversation Mergin Two Collections Only Returns One

Hi everybody, I have two laravel collections (posts and events), I merge both into a new cllection called sliderItems, hoever this collection only returns one of the collections intead of a merged one with both, in this case only posts.

$sliderPosts = Post::where('isFeatured', true)->where('isVisible', true)->with('postcategory')->latest()->get();
        //dump($sliderPosts);
        $sliderEvents = Event::where('isFeatured', true)->where('isVisible', true)->latest()->get();
        //dump($sliderEvents);
        $sliderItems = $sliderEvents->merge($sliderPosts)->take(4);
        //dump($sliderItems);
19 May
4 weeks ago

Gabotronix started a new conversation Pause/Play In My Custom Vue Slider

Hi everybody, I made a custom vue slider and it works so far but I had the idea to add pause/play button to my slider, issue is I don't know how can I handle pausing and resuming setInterval of my slider, I want a function to toggle pause/play in my component:

Here is my component:

<template>
<section class="SLIDERcontainer8_maincontainer">
    <transition-group name="slider-fade">
        <div class="SLIDERcontainer8_image move" :style="'background-image:url('+item.image+');'" v-for="(item, index) in slideritems" :key="item.title" :class="{ 'active_slider' : activeslider == index }"></div>
    </transition-group>
    <div class="SLIDERcontainer8_dots_container">
        <button class="SLIDERcontainer8_dot fs_normal c_light" :class="{ 'active_dot' : index == activeslider }" v-for="(slider, index) in slideritems" :key="index" @click="goToSlider(index)" type="button">{{ slider.title }}</button>
    </div>
</section>
</template>
<!--SCRIPTS-->
<script>
import { mapState } from 'vuex';
export default {
name: 'SLIDERcontainer7',


computed:
{
    ...mapState('Globals', ['globals'])
},


props:
{
    sliderinterval: { default: 5000, type: Number },
    slideritems: { required:true }
},


data() {
    return {
        sliderTimer: 0,
        activeslider: 0,
    }
},


mounted() {
    console.log(this.$options.name+' component successfully mounted');
    this.startSlider();
},


methods:{


    startSlider() {
        var self = this;
        this.activeslider = 0;
        clearInterval(this.sliderTimer);
        this.sliderTimer = setInterval(() => {
        self.nextSlider() }, self.sliderinterval);
    },


    prevSlider() {
        if(this.activeslider == 0){
            this.activeslider = this.slideritems.length - 1;
        }
        else{
            this.activeslider = this.activeslider - 1;
        }
    },


    nextSlider() {
        if(this.activeslider == this.slideritems.length - 1){
            this.activeslider = 0;
        }
        else{
            this.activeslider = this.activeslider + 1;
        }
    },


    goToSlider (sliderIndex) {
        var self = this;
        this.activeslider = sliderIndex;
        clearInterval(this.sliderTimer);
        this.sliderTimer = setInterval(() => {
        self.nextSlider() }, self.sliderinterval);
        
    },

}


};
</script>
<!--STYLES-->
<style scoped>
.active_slider{display:flex !important;}
.active_dot{background-color:var(--web_primary_color) !important;}
.SLIDERcontainer8_maincontainer{width:100%; height:70vh; position:relative; overflow:hidden; margin:0px 0px 0px 0px;}
.SLIDERcontainer8_image{display:none; width:100%; height:100%; background-size:cover; background-position:center; position:absolute; top:0px; left:0px;}
.SLIDERcontainer8_dots_container{width:100%; height:75px; flex-wrap:no-wrap; background-color:rgba(49,47,84,0.95); display:flex; justify-content:center; align-items:center; position:absolute; bottom:0px; left:0px;}
.SLIDERcontainer8_dot{cursor:pointer; height:100%; display:flex; border-right:1px solid rgba(0,0,0,0.2); align-items:center; justify-content:center; text-align:center; flex:1; padding:0px 20px;}
.SLIDERcontainer8_dot:hover{background-color:var(--web_primary_color) !important;}
@media only screen and (max-width: 736px) 
{
.SLIDERcontainer8_maincontainer{width:100%; height:250px; position:relative; overflow:hidden; margin:0px 0px 0px 0px;}
.SLIDERcontainer8_image{display:none; width:100%; height:100%; background-size:cover; background-position:center; position:absolute; top:0px; left:0px;}
.SLIDERcontainer8_dots_container{width:100%; height:40px; flex-wrap:no-wrap; background-color:rgba(49,47,84,0.95); display:flex; justify-content:center; align-items:center; position:absolute; bottom:0px; left:0px;}
.SLIDERcontainer8_dot{width:15px; height:15px; text-indent: -9999px; background-color:white; display:flex; border-radius:50%; margin:0px 5px; border-right:0px solid rgba(0,0,0,0.2); align-items:center; justify-content:center; text-align:center; flex:none; padding:0px 0px;}
.SLIDERcontainer8_dot:hover{background-color:var(--web_primary_color) !important;}
}
</style>


Please help me out.

16 May
1 month ago

Gabotronix left a reply on Cache Busting With Laravel Mix.version() Not Working

After seeing another comment I ran npm run production and now the manifest file shows hashed paths as it should, now this may seem like a noobish question and I'm indeed one, I have a DigitalOcean production server where I hos my apps, I have NEVER ran npm run production for my laravel/vue app to work, I just use git to clone files into /var/www/app, do a composer install and npm install and voila, so... maybe I should use npm run production after pulling changes from git into my live server? can someone shed some light on this?

Gabotronix started a new conversation Cache Busting With Laravel Mix.version() Not Working

Hi everybody, I just noticed that mobile chrome shows an old cached version of my page (I tried in incognito and it always returns newest version), I tried to solve this by adding Cache Control: must-revalidate and max-age="0" using a global middleware, this didn't work either.

Now since I'm using laravel-mix with my laravel/app I tried using mix.version() but this isn't working either... I checked my mix manifest file and it looks like this:

{
    "/js/app.js": "/js/app.js",
    "/css/app.css": "/css/app.css"
}

And my mix dile looks like this:

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .version();

This is how I access js file in my blade layout:

<script src="{{ mix('/js/app.js') }}"></script>
</body>

None of the mentioned solutions worked and it's geting quite depressing...

I don't want to add query string versioning myself too...

15 May
1 month ago

Gabotronix left a reply on Multiple Laravel Form Request Validation Rules In A Single File

@MUSHOOD - This does look my man but I'm not a fan of adding an input variable into my payloads just to get this to work, wuld it be possible to DI it in the controller method arguments or similar?

Thanks in advance.

14 May
1 month ago

Gabotronix started a new conversation Multiple Form Reuqest Validation Rules In A Single File

Hi everubody, I was wondering if anyone thought of a way to have multiple request rules inside a single file? currently I have some folders like reviews, posts where I have CRUD validation rules and many other form request files related to my models, however I think having all validation rules inside a single php file like App\Http\Requests\Reviews would be awesome.

Not sure how I could DI inject them in my controller methods like with normal laravel Form Requests.

Any ideas?

12 May
1 month ago

Gabotronix started a new conversation Chrome On Mobile Showing Old Cache Version Of My Web

Hi everybody, I noticed on mobile chrome is showing an old version of my website, I have made some git pulls since I first deployed it but still shows outdated version, this is fixed if I open incognito page but this is not very handy lol.

I have done some research and found in SO the following excerpt:

<?php Header("Cache-Control: max-age=3000, must-revalidate"); ?>

"You can implement a PHP script that must be the first line of code in your index file . It is an http header typically issued by web servers. You can also rename the resource that is considered "stale". This tutorial will give you more details. https://www.mnot.net/cache_docs/"

https://stackoverflow.com/questions/26111389/chrome-keeps-loading-a-old-cache-of-my-website

I have been thinking of where I should place that code in my laravel app? how would you go about this?

11 May
1 month ago

Gabotronix started a new conversation Make Css Animation Smoothly Loop Forever

Hi every body, I'm trying to make my css animation look snapier, I want it to loop forever and do so smoothly, last frame should look like first frame but right now, when the animation finishes, it SNAPS back to the original state. I want to use this effect form my custom slider.

Here is my code:

.move{animation: move 30s ease;
  -ms-animation: move 30s ease; 
  -webkit-animation: move 30s ease; 
  -moz-animation: move 30s ease;
}


@keyframes move {
  0%{
    -webkit-transform-origin: bottom top;
    -moz-transform-origin: bottom top;
    -ms-transform-origin: bottom top;
    -o-transform-origin: bottom top;
    transform-origin: bottom top;
    transform: scale(1.0);
    -ms-transform: scale(1.0);
    -webkit-transform: scale(1.0);
    -o-transform: scale(1.0);
    -moz-transform: scale(1.0);
  }

  100% {
    transform: scale(1.3);
    -ms-transform: scale(1.3);
    -webkit-transform: scale(1.3);
    -o-transform: scale(1.3);
    -moz-transform: scale(1.3);
  }
}
10 May
1 month ago
09 May
1 month ago

Gabotronix started a new conversation Issue With Z-index

Hi everybody, I'm trying to place the div with red outline over the one with yellow outline but I'm having issues, despite both divs having a position the yellow one sticks over the red one.

Any ideas?

<section class="LAYOUTbanner1_maincontainer">
    <div class="LAYOUTbanner1_image_container">
        <div class="LAYOUTbanner1_image_first" style="background-image:url('/img/misc/default.jpg');">
            <div class="LAYOUTbanner1_image_second" style="background-image:url('/img/misc/default.jpg');"></div>    
        </div>
    </div>
</section>
<style scoped>
.LAYOUTbanner1_maincontainer{width:100%; height:auto; display:flex; margin:40px 0px;}
.LAYOUTbanner1_image_container{width:45%; height:auto; display:flex; justify-content:center; align-items:center;}
.LAYOUTbanner1_image_first{width:250px; height:250px; outline:1px solid red; margin:40px 0px; position:relative; background-size:cover; background-position:center; z-index:2;}
.LAYOUTbanner1_image_second{width:250px; height:250px; outline:1px solid yellow; position:absolute; background-size:cover; background-position:center; top:50px; left:50px; z-index:1;}
@media only screen and (max-width: 736px) 
{

}
</style>
03 May
1 month ago

Gabotronix left a reply on Vue: Issue Applying Class When Element Is Not In View

@BOBBYBOUWMANN - Yeah I get a console.log when scrolling.

Gabotronix started a new conversation Vue: Issue Applying Class When Element Is Not In View

Hi everybody, I want to apply a class to a DOM element only when this element is in view inside my viewport (any part of it appearing on screen), however my console log says it's always not in view so the css class is not being applied. For this purpose I'm using a vue directive and a scroll event listener, here is my directive:

Vue.directive('focus-toggle-class', {
    isLiteral: true,
    inserted: (el, binding, vnode) => {
        
        let scrolled = false;
        let rect = {};
        
        let checkInView = function(){
            if (inView) {
                el.classList.add(binding.value);
                console.log('in view');
            }
            else{
                el.classList.remove(binding.value);
                console.log('not in view');
            } 
        };

        window.addEventListener('load', function() {
            rect = el.getBoundingClientRect();
            console.log(rect);
            checkInView();
            window.addEventListener('scroll', function() {
                scrolled = true;
            });
        });

        let inView = (
            rect.top >= 0 &&
            rect.left >= 0 &&
            rect.right <= (window.innerWidth || document.documentElement.clientWidth) &&
            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
        )

        let timeout = setInterval(function() {
            if (scrolled) {
                scrolled = false;
                checkInView();
            }
        }, 2000);

    }
});
02 May
1 month ago

Gabotronix started a new conversation Font Face Not Working On Production

Hi everybdy, I have some local fonts downloaded inside my public folder:

app/public/fonts/Walking In The Street

They work all right in my local dev machine but not in my production server...

So fart this is what I have tried:

1)Adding this line to mix file:

mix.copyDirectory('resources/fonts', 'public/fonts');

2)Changing from :

@font-face { font-family: Walking In The Street; src: url('/fonts/Walking In The Street.ttf'); }

to

@font-face { font-family: Walking In The Street; src: url('../public/fonts/Walking In The Street.ttf'); }

None of these worked...

01 May
1 month ago

Gabotronix started a new conversation Mailgun Service Provider For Mailgun Client Credentials

First of all, I know laravel already has a wrapper for Mailgun but laravel doesn't support Mailgun batch sending so I HAVE to use Mailgun php sdk in laravel which I finally got working, however I think having to do the following:

$mailgun = Mailgun::create(config('mail.mailgunSecret')); 

before sending the messages with mailgun is a little repetitive, with other API like Stripe I make a serviceprovider and instantiate it like this:

<?php
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Stripe\Stripe;


class StripeServiceProvider extends ServiceProvider
{
    public function boot()
    {
    
        Stripe::setApiKey(config('services.stripe.secret'));
        
    }
}

But I don't know if I'm able to do something like this with mailgun since this is how I'm sending mails currently.

$mailgun = Mailgun::create(config('mail.mailgunSecret')); 

        $result = $mailgun->sendMessage(config('mail.mailgunDomain'), [
            'from' => config('mail.from'),
            'to' => $emails,
            'subject' => '%recipient.first% no te pierdas lo último de '.config('app.name'),
            'html' => $html,
            'recipient-variables' => '{ "[email protected]": {"first":"Gabriel", "id":1}, "[email protected]": {"first":"Silvia", "id":2} }'
        ]);

Any advice?

Gabotronix started a new conversation Vue: Component Method From Vuex Module?

Hi everybody, I'm using namespaced modules for state management in vuex, I try to keep all my actions mutations inside my modules as this helps me keep most of my code in the same place (modules acting like classes or similar) hoever there's an issue, I'd like to fire a component method to clear a form when a vuex action is successfull (that is the axios request gets an OK/200 response) but sadly I can't fire a methos from vuex module into my component ( there's no this inisde module).

I also tried adding a .then to my action call but it fires right after I call the action...

I guess I could move the action into the component itself but I'd rather not, what do you guys suggest?

My component:

stripeSourceHandler: function(sourceId)
    {
        if(this.customerSources.length == 0)
        {
            console.log('createSourceAndCustomer');
            this.createSourceAndCustomer({ id: sourceId });
        }
        else
        {
            console.log('addSource');
            this.addSource({ id: sourceId }).then(alert('Form cleared')); //this fires right after calling addSource
        };
    },

My module action:

addSource({ commit }, sourceId)
    {
        commit('Loader/SET_LOADER', { status:1, message: 'Procesando...' }, { root: true });
        axios.post('/stripe/add-source', sourceId)
        .then((response) => {
            commit('Loader/SET_LOADER', { status:2, message: response.data.message }, { root: true });
            commit('ADD_SOURCE', response.data.customer);
            //I can't clear component form from this...
        }, 
        (error) => {
            commit('Loader/SET_LOADER', { status:3, errors: error, message: 'Error al añadir el pago.' }, { root: true });
        });
    },
30 Apr
1 month ago

Gabotronix started a new conversation App Url In Mail Template

Hi everybody, I'm trying to put a link to my web app in my blade mail template, however the url is showing like this : http://127.0.0.1:8000/.$code->discount->url. instead of a properly built, valid url.

This is how I'm doing it:

<a href="{{ url('.$code->discount->url.') }}"><img src="{{ $code->discount->image }}" style="min-width:175px; max-width:175px; min-height:125px; max-height:125px; border:1px solid rgba(0,0,0,0.3); margin:0px 20px 0px 0px;"></a>

I also tried with:

<a href="{{ $code->discount->url }}"><img src="{{ $code->discount->image }}" style="min-width:175px; max-width:175px; min-height:125px; max-height:125px; border:1px solid rgba(0,0,0,0.3); margin:0px 20px 0px 0px;"></a>

Second way only gave me a partial url (see bellow), not the full url host and path).

$code->discount->url is /promociones/hamburguesa-de-queso

29 Apr
1 month ago

Gabotronix started a new conversation Stripe Js: Don't Let Empty Form Be Sent.

Hi everybody, I'm trying to avoid letting users submit stripe form when inputs are empty, I`m using stripe.js elements integration to render my form and handle form submition inside my vue component.

this.cardNumberElement.on('change', this.enableForm);
this.cardExpiryElement.on('change', this.enableForm);
this.cardCvcElement.on('change', this.enableForm);

After checking the docs I tried to use the change event on inputs but this is not working sice the user can just not type anything and click submit button.

This is my component:

mounted()
{
    console.log(this.$options.name + ' component succesfully mounted');

    this.stripe = Stripe(this.stripePK);
    this.elements = this.stripe.elements();

    this.cardNumberElement = this.elements.create('cardNumber', {style: this.stripeStyles});
    this.cardNumberElement.mount('#card-number-element');
    this.cardExpiryElement = this.elements.create('cardExpiry', {style: this.stripeStyles});
    this.cardExpiryElement.mount('#card-expiry-element');
    this.cardCvcElement = this.elements.create('cardCvc', {style: this.stripeStyles});
    this.cardCvcElement.mount('#card-cvc-element');

    let stripeElements = document.querySelectorAll("#card-number-element, #card-expiry-element, #card-cvc-element");
    stripeElements.forEach(el => el.addEventListener('change', this.printStripeFormErrors));
    this.cardNumberElement.on('change', this.enableForm);
    this.cardExpiryElement.on('change', this.enableForm);
    this.cardCvcElement.on('change', this.enableForm);
},

methods: 
{
    ...mapActions('Stripe', ['addSource', 'createSourceAndCustomer']),
    ...mapMutations('Stripe', ['TOGGLE_PAYMENT_FORM']),
    ...mapMutations('Loader', ['SET_LOADER', 'SET_LOADER_ID']),

    enableForm:function(event){
        if(event.complete){
            this.disabled = false;
        }
        else if(event.empty){
            this.disabled = true;
        }
    },


    submitStripeForm: function()
    {
        this.SET_LOADER({ status:1, message: 'Procesando...' });
        var self = this;

        this.stripe.createSource(this.cardNumberElement).then(function(result) {
            if (result.error) {
                self.cardErrors = result.error.message;
            }
            else {
                self.stripeSourceHandler(result.source.id);
            }
        });   
    },


    stripeSourceHandler: function(sourceId)
    {
        console.log('stripeSourceHandler');
        
        this.cardNumberElement.clear();
        this.cardExpiryElement.clear();
        this.cardCvcElement.clear();

        if(this.customerSources.length == 0)
        {
            console.log('createSourceAndCustomer');
            this.createSourceAndCustomer({ id: sourceId });
        }
        else
        {
            console.log('addSource');
            this.addSource({ id: sourceId });
        }
    },


    printStripeFormErrors: function(event)
    {
        if(event.error)
        {
            self.cardErrors = event.error.message
        } 
        else
        {
            self.cardErrors = '';
        }
    }  
}