Gabotronix

Gabotronix

Member Since 1 Year Ago

Experience Points 20,030
Experience Level 5

4,970 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.

22 May
1 day 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
2 days 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 days 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 week 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 week 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 week 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 week 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 week 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 week ago
09 May
2 weeks 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
2 weeks 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
3 weeks 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
3 weeks 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
3 weeks 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
3 weeks 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 = '';
        }
    }  
}
28 Apr
3 weeks ago

Gabotronix started a new conversation First Argument To Stream::create() Must Be A String Error When Using Mailgun Sdk

Hi everybody, I'm using Mailgun php sdk to send batch mails with Mailgun php sdk however I'm getting the following error:

InvalidArgumentException  : First argument to Stream::create() must be a string, resource or StreamInterface.

  at C:\xampp\htdocs\dtcburger.com\vendor\nyholm\psr7\src\Stream.php:87
    83|
    84|             return $new;
    85|         }
    86|
  > 87|         throw new \InvalidArgumentException('First argument to Stream::create() must be a string, resource or StreamInterface.');
    88|     }
    89|
    90|     /**
    91|      * Closes the stream when the destructed.

  Exception trace:

  1   Nyholm\Psr7\Stream::create(Object(Illuminate\Support\Collection))
      C:\xampp\htdocs\dtcburger.com\vendor\nyholm\psr7\src\Factory\HttplugFactory.php:29

  2   Nyholm\Psr7\Factory\HttplugFactory::createStream(Object(Illuminate\Support\Collection))
      C:\xampp\htdocs\dtcburger.com\vendor\php-http\multipart-stream-builder\src\MultipartStreamBuilder.php:61

  Please use the argument -v to see more details.

This is my code:

$mailgun = Mailgun::create(env('MAILGUN_SECRET')); 


        $result = $mailgun->sendMessage(config('mail.mailgunDomain'), [
            'from' => config('mail.username'),
            'to' => $emails,
            'subject' => $mailData['subject'],
            'text' => 'Hi',
            'recipient-variables' => $json
        ]);

Gabotronix started a new conversation Map By Key And Get Result In Json

Hi everybody, I'm using mailgun API and batch sending , in order to properly send batch mails with recipent variables I must provide a valid JSON-encoded dictionary, where key is a plain recipient address and value is a dictionary with variables.

The JSON object I wanna obtain is as follows:

'{ "[email protected]": {"username":"Bob", "id":1} ,
 { "[email protected]": {"first":"Pete", "id":2} ,'

This is what I have so far (pseudocode):

$subs = Sub::all();

        foreach($subs as $sub)
        {
            $username = mailName($email->email);
            $id = $sub->id;
        }

How could I do this, is it possible to do with laravel collection methods?

Thanks in advance and sorry for noob question.

27 Apr
3 weeks ago

Gabotronix started a new conversation Perfectly Smooth Looped Eased Css Animation

Hi everybody, I'm trying toanimate an element to slowly move from left to right a small ammount of distance and do it in a smooth way but the result is not very good.

Here is what I have so far:

.animate_sideways{animation:sideways 5s linear infinite; animation-timing-function: ease-in, ease-in-out;};
@keyframes sideways {
  50% {
    transform: translateX(30px);
  }
  100% {
    transform: translateX(-30px);
  }
}

Gabotronix started a new conversation Error When Tryining To Delete Mysql Database;

Hi everybody, I'm trying to delete a mysql database in my DigitalOcean VPS but when I enter drop command I get the following error:

ERROR 6 (HY000): Error on delete of './gabrielgb//db.opt' (Errcode: 13 - Permission denied)

Any idea how I can fix this?

Gabotronix started a new conversation Open Ports For Mailgun In Production VPS (DigitalOcean)

Hi everybody I have a VPS with DigitalOcean where I wanna host some laravel apps, one of my apps uses Laravel's Mailgun integration to send emails, I was wndering if I should open ports with ufw in order to Mailgun to work in production (587 in my .env file), currently my ufw configuration is as follows:

Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
Nginx Full                 ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
Nginx Full (v6)            ALLOW       Anywhere (v6)

Thanks in advance

Gabotronix started a new conversation Git : Remote: HTTP Basic: Access Denied

Hi everybody, I'm trying to push somecode to a remote repo I created in gitlab however when I do folowing command:

git push -u origin master

to push code in master to my online repo I get the following error message in shell:

On branch develop
nothing to commit, working tree clean

C:\xampp\htdocs\gabrielgb.es>git push -u origin master
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.com/GabotronES/gabrielgb.es.git/'

How can I solve this? I might have change my password and I don't remember... how can I proceed?

26 Apr
3 weeks ago

Gabotronix started a new conversation GoDaddy Blocked My Domain, How To Unblock?

Hi everbody, I missed the mail confirmations for a domain name I got recently, now I just noticed it's blocked and I can't seem to find how to do this?

I follow the steps in the web but the options I have to click are disabled and I think I might not be able to unlock it for 60 days, any idea what I can do?

25 Apr
4 weeks ago

Gabotronix left a reply on Scheduling SQL Backups With Laravel Outside Storage Path

@SNAPEY - afaik Spatie's package can only sore inside laravel's folder structure so they are STILL in my VPS, ideally I'd like to dowload this to my google drive but it seems like a pain to set up.

Gabotronix started a new conversation Scheduling SQL Backups With Laravel Outside Storage Path

Hi everybody, I know it's possible to schedule commands to be run with laravel and cron job, my goal is tro create a command to backup my sql databases into my home directory inside my VPS, the example I found uses laravel storage path to drop the backups but I was wondering how can I choose another file outside my laravel app folder (my user home directory for example), is it possible to do?

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class BackupDatabase extends Command
{
    protected $signature = 'db:backup';

    protected $description = 'Backup the database';

    protected $process;

    public function __construct()
    {
        parent::__construct();

        $this->process = new Process(sprintf(
            'mysqldump -u%s -p%s %s > %s',
            config('database.connections.mysql.username'),
            config('database.connections.mysql.password'),
            config('database.connections.mysql.database'),
            storage_path('backups/backup.sql')
        ));
    }

    public function handle()
    {
        try {
            $this->process->mustRun();

            $this->info('The backup has been proceed successfully.');
        } catch (ProcessFailedException $exception) {
            $this->error('The backup process has been failed.');
        }
    }
}

Gabotronix left a reply on Sending Mail Blade Template With Variables Through Mailgun Php SDK.

@BOBBYBOUWMANN - Noted, do you have any idea how to send batch emails through Mailgun using laravel Mail facade? I guess it would be possible to extend this feature but I haven't found any example or tutorial.

Gabotronix left a reply on Issue Installing Mailgun\Bogardo Package With Composer In Laravel

@MVD - But then how can I use Mailgun features like batch sending? I think I DO need to install the php SDK, however I'm not sure I can send blade templates with variables through the SDK, can someone shed some light on me?

Gabotronix started a new conversation Sending Mail Blade Template With Variables Through Milgun Php SDK.

Hi everybody, I'm using Mailgun's php SDK to send mails, after looking through the docs you can apparently send html/text mails but what about laravel's blade templates, my templates have some variables like order details and user info that I want my templates to have, is it possible to do?

So my questions are:

How can I share variables with my blade templates and send them through Mailgun's API.

How can I reference my my blade templates when filling the parameters of my mailgun API call.

I 'd rather not download any composer package like Bogardo since they are outdated.

This is what I have so far:

public static function sendMailGun($order)
    {
        $mailData = [
            'subject' => 'Tus códigos de descuento para '.config('app.name').'.',
            'destination' => $order['purchaser']['email'],
            'order' => $order
        ];

        $mg = Mailgun::create('YOUR_API_KEY');
        //how can I pass $mailData into my views?
        $mg->messages()->send('YOUR_DOMAIN_NAME', [
            'from'    => 'Excited User <[email protected]_DOMAIN_NAME>',
            'to'      => 'Baz <[email protected]_DOMAIN_NAME>',
            'subject' => $mailData['subject'],
            'html'    => 'I WANT TO REFERENCE emails.discount-mail.blade.php HERE'
        ]);
    }

Gabotronix started a new conversation Issue Installing Mailgun\Bogardo Package With Composer

Hi everybody, I'm currently trying to install Bogardo\Mailgun composer package with the following command:

composer require bogardo/mailgun

however after running the command there's a problem with dependencies, I'm not sure how I could fix this since I don't have much experience with composer. Using npm I have npm audit fix command which takes care of fixing any conflicts but how can I fix m issue here?

This is what my command prompt shows:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install bogardo/mailgun v5.0.4
    - Conclusion: don't install bogardo/mailgun v5.0.3
    - Conclusion: don't install bogardo/mailgun v5.0.2
    - Conclusion: don't install bogardo/mailgun v5.0.1
    - Conclusion: remove nesbot/carbon 2.17.0
    - Installation request for bogardo/mailgun ^5.0 -> satisfiable by bogardo/mailgun[v5.0.0, v5.0.1, v5.0.2, v5.0.3, v5.0.4].
    - Conclusion: don't install nesbot/carbon 2.17.0
    - bogardo/mailgun v5.0.0 requires nesbot/carbon ^1.21 -> satisfiable by nesbot/carbon[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.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].
    - Can only install one of: nesbot/carbon[1.26.3, 2.17.0].
    - Can only install one of: nesbot/carbon[1.26.4, 2.17.0].
    - Can only install one of: nesbot/carbon[1.27.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.28.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.29.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.29.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.29.2, 2.17.0].
    - Can only install one of: nesbot/carbon[1.30.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.31.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.31.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.32.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.33.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.34.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.34.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.34.2, 2.17.0].
    - Can only install one of: nesbot/carbon[1.34.3, 2.17.0].
    - Can only install one of: nesbot/carbon[1.34.4, 2.17.0].
    - Can only install one of: nesbot/carbon[1.35.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.35.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.36.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.36.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.36.2, 2.17.0].
    - Can only install one of: nesbot/carbon[1.21.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.22.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.22.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.23.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.24.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.24.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.24.2, 2.17.0].
    - Can only install one of: nesbot/carbon[1.25.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.26.0, 2.17.0].
    - Can only install one of: nesbot/carbon[1.26.1, 2.17.0].
    - Can only install one of: nesbot/carbon[1.26.2, 2.17.0].
    - Installation request for nesbot/carbon (locked at 2.17.0) -> satisfiable by nesbot/carbon[2.17.0].


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

Gabotronix started a new conversation Mail Batch Sending With Mailgun And Laravel

Hi everybody, I set up my laravel app to use mailgun driver for sending emails, now I want to use one of Mailgun's features, that is batch sending, however using laravel's Mail facade doesn't let me do batch sending, atleat I haven't seen any tutorials where they do this.

Is it possible? maybe I should download Mailgun's php SDK instead and do it just like in mailgun docs.

23 Apr
1 month ago

Gabotronix started a new conversation Scheduling Sending Multiple Queued Mails

Hi everybody, I want to bulk send emails to many (around 300-600) mails using laravel scheduler, for this purpose I created a command to run along with laravel's task scheduler.

As for my mail API, I'm using laravel's integratin of the Mailgun API, Mailgun lets you send thoushands of them.

I also want to run the mail sending through a queue, afaik using a queue is specially for performance heavy tasks such as sending mail.

My command for sending mails:

<?php
namespace App\Console\Commands;


use Illuminate\Console\Command;
use Mail;
use App\Models\Event;
use App\Models\Discount;
use App\Models\General;
use App\Models\Sub;
use App\Mail\weekly\WeeklyMail1;


class SendWeeklyMail1 extends Command
{
    

    protected $signature = 'emails:weekly';
    protected $description = "What's new this week? send weekly emails to subbed users";

    
    public function __construct()
    {
        parent::__construct();
    }

    
    public function handle()
    {

        $emails = [ '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]',
        '[email protected]', '[email protected]', '[email protected]',
        '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]', 
        '[email protected]', '[email protected]', '[email protected]' ];

        $mailData = [
            'subject' => 'Últimas novedades en '.env('APP_NAME'),
            'events' => $events,
            'discounts' => $discounts,
        ];

        foreach ($emails as $email)
        {
            Mail::to( $email )->queue(new WeeklyMail1($mailData));
        };
    }


}

As for my questions, is this a good, performant way to send multiple mails with laravel scheduler?

Will each of my mails be properly sent to the queue for dispatching?

When I run php artisan schedule:run òn my local dev machine (Windws) I get the following message:

C:\xampp\htdocs\dtcburger.com>php artisan schedule:run Running scheduled command: "C:\xampp\php\php.exe" "artisan" App\Console\SendWeeklyMail1 > "NUL" 2>&1

But nothing happens after that, I haven't received any emails.

Kernel file:

protected $commands = [ 'App\Console\Commands\SendWeeklyMail1', 'App\Console\Commands\SendBulletinMail1', ];

protected function schedule(Schedule $schedule)
{
    $schedule->command(SendWeeklyMail1::class);
}

Gabotronix started a new conversation Removing Img Elements From Html String With Vue Filter

Hi everybody, I want to make a filter that : -Truncates text by a given number of charactaers -Remove image elements from the html string -The number of characters must be always the same, this means the removed characters from an image element must be taken into account when truncating text.

Help me finish this method guys, the part I'm having a harder time is take into account the characters removed from image element, when I say remove image what I mean is mean is actually removing the whole element string:

<img> and everything in between </img>

This is my method for now:

Vue.filter('truncate', function (value, limit = 30) {
    if(!value) return '';
    
    if (value.length > limit) {
        value = value.substring(0, (limit - 3)) + '[...]';

    }
    //must always return value *anything
    return value;
})

This is how I apply filter in my template:

<section class="EVENTcard1_maincontainer" v-if="event">
           <div class="EVENTcard1_item_info_description fs_normal c_normal" v-html="$options.filters.truncate(event.body, 400)"></div>
            
</section>
</template>
21 Apr
1 month ago

Gabotronix started a new conversation Trait/Scope For My Custom Laravel Paginate Method

Hi everybody, I want to implement my own pagination for vue and laravel, instead of using get like laravel I want to make use POST ajax requests from my custom vue pagination component.

For that I want to implement something similar to a scope I can apply to my Eloquent models, I want that scope to return the total number of records from my model in database and a specific number of records along with it.

With this two data I can hydrate my pagination component, since I'm not really sure how to approach this (use Trait?, a scope?, return JSON? or collection maybe?) I leave my pseudocode bellow:

public function scopeGetPaginate($query, $perPage)
    {
        
        $pageResults = $query->take($perPage)->get();

        $totalResults = Model::count();

        return response()->json([
            'pageResults' => $pageResults,
            'totalResults' => totalResults,
        ], 200);
    }
18 Apr
1 month ago

Gabotronix started a new conversation Issue With Chart.js And Vue

Hi everybody, I'm trying to use chart.js with vue, so far results have been good but when I get my chart data via axios (data is not there when chart component is mounted) my chart doesn't display anything, I'm trying to come up with a method to rerender the charts when data in my component is actually there instead of waiting for the ajax call to complete but I haven't found a solution...

I pass all relevant data for my chart via props to my chart component, here is how it looks:

<template>
<section class="CHARTmaincontainer">
    <canvas :id="id" :width="width" :height="height"></canvas>
</section>
</template>
<!--SCRIPTS-->
<script>
import Chart from 'chart.js';
export default {
name: 'ChartJS',


props:
{
    id:{ required:true, type:String },
    type:{ default:'bar', type:String },
    width:{ default:400, type:Number},
    height:{ default:175, type:Number },
    data:{ required:true, type:Array },
    label:{ default:'Gráfico', type:String },
    labels:{ required: true, type:Array } 
},


mounted()
{
    let ctx = document.getElementById(this.id);
    let chart = new Chart(ctx, {
    type: this.type,
    data: {
        labels: this.labels,
        datasets: [{
            label: this.label,
            data: this.data,
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255, 99, 132, 1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true
                },
                gridLines: {
                    display: true
                }
            }],
            xAxes: [{
                ticks: {
                    beginAtZero: true
                },
                gridLines: {
                    display: true
                }
            }]
        },
    },
    legend: {
        display: false
    },
    tooltips: {
        enabled: true,
        mode: 'single',
        callbacks: {
            label: function(tooltipItems, data) {
                return '$' + tooltipItems.yLabel;
            }
        }
    },
    responsive: true,
    maintainAspectRatio: false,
    });
},


};
</script>
<!--STYLES-->
<style scoped>
.CHARTmaincontainer{width:100%; display:flex; flex-direction:column; height:auto; margin:20px 0px;}
</style>

And here is the component where I place my chart components and where data is passed:

<template>
<section class="entry_maincontainer">
    <chart-js v-if="ordersCount"
        :id="'grafico1'"
        :data="ordersCount"
        :label="'Descuentos vendidos'"
        :labels="['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Ago', 'Oct', 'Nov', 'Dic']">
    </chart-js>
</section>
</template>
<!--SCRIPTS-->
<script>
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex';
export default {
name: 'StatsPanel',


computed:
{
    ...mapState('Orders', ['orders']),
    ...mapGetters('Orders', ['ordersCount', 'ordersTotal']),
    ...mapState('Globals', ['globals']),
    ...mapState('Loader', ['loader']),
},


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


methods:
{
    ...mapActions('Orders', ['getAll']),
    ...mapMutations('Loader', ['RESET_LOADER']),
}


};
</script>
<!--STYLES-->
<style scoped>
</style>

My getter, this is the main data prop used to render my chart:

ordersCount: state => {

        let monthlyCount = { Enero:0, Febrero:0, Marzo:0, Abril:0, Mayo:0, Junio:0, Julio:0, Agosto:0, Septiembre:0, Octubre:0, Noviembre:0, Diciembre:0 };
        
        _.forEach(state.orders,  function(order) { 
            let capitalizedMonth = _.upperFirst(Vue.moment(order.created_at).format('MMMM'));
            monthlyCount[capitalizedMonth] = parseInt( monthlyCount[capitalizedMonth] ) + parseInt( order.discountcodes.length );
        });

        let values = Object.values(monthlyCount);

        return values;
    },
16 Apr
1 month ago

Gabotronix started a new conversation Laravel Form Request Custom Error Message For Regex Rule

Hi everybody, I'm trying to display a custom validation error message for my regex inside Form Request, I haven't succeded so far.

This is my Form Request logic, regex rule only accepts letters and numbers.

<?php

namespace App\Http\Requests\discounts;

use Illuminate\Foundation\Http\FormRequest;

class CheckoutCode extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'code' => 'required|string|min:7|max:7|regex:/([A-Za-z0-9 ])+/',
        ];
    }


    public function messages()
    {
        return [
            'code.regex' => 'Estas jodido'
        ];
    }


}

Gabotronix started a new conversation Trying To Make My Mail Table Responsive

Hi everybody, I have a table with two rows, left row holds an image and right some text, I want to make this table responsive so when on mobile both rows hold all the horizontal space and the right row goes bellow the first row, making it somewhat fluid.

This is my template:

@if(count($mailData['order']['discountcodes']) > 0)
@foreach($mailData['order']['discountcodes'] as $code)
---
<br>
# {{ $code->discount->title }} (-{{ $code->discount->discountPercent }}%)
<table style="width:100%; table-layout:fixed;" >
  <tr>
    <td class="left_column"><img src="{{ $code->discount->image }}" style="min-width:150px; max-width:150px; min-height:100px; max-height:100px; border:1px solid rgb(150,150,150);"></td>
    <td class="right_column"><p>Precio:{{ $code->discount->finalPrice }}</p><strong><p>CÓDIGO: {{ $code->unicode }}</p></strong></td>
  </tr>
</table>
<br>
---
@endforeach
@endif
# Total:{{ $mailData['order']['cartTotalPrice'] }}
<br>
<br>
Disruta Tu Compañia,
<br>
{{ env('APP_NAME') }}
@endcomponent
<style>
.left_column{text-align:left; display:inline-block; width:150px;}
.right_column{text-align:left; display:inline-block; vertical-align:top; padding:0px 0px 0px 20px;}
@media only screen and (max-width: 480px) 
{
.left_column{width:100% !important; display:block !important;}
.right_column{width:100% !important; display:block !important;}
}
</style>
15 Apr
1 month ago

Gabotronix started a new conversation Error Using Composer To Install Bogardo/Mailgun And Php-http/guzzle6-adapter

Hi everybody, I'm trying to install a mailgun laravel package called Bogardo/Mailgun along with with php-http/guzzle6-adapter.

I had no problem when using to install first package using folowing command:

composer require bogardo/mailgun

However when I use:

composer require php-http/guzzle6-adapter

I get the following composer error:

C:\xampp\htdocs\dtcburger.com>composer require php-http/guzzle6-adapter
Using version ^2.0 for php-http/guzzle6-adapter
./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
    - nexmo/client 1.7.0 requires php-http/guzzle6-adapter ^1.0 -> satisfiable by php-http/guzzle6-adapter[v1.0.0, v1.1.0, v1.1.1] but these conflict with your requirements or minimum-stability.
    - nexmo/client 1.7.0 requires php-http/guzzle6-adapter ^1.0 -> satisfiable by php-http/guzzle6-adapter[v1.0.0, v1.1.0, v1.1.1] but these conflict with your requirements or minimum-stability.
    - nexmo/client 1.7.0 requires php-http/guzzle6-adapter ^1.0 -> satisfiable by php-http/guzzle6-adapter[v1.0.0, v1.1.0, v1.1.1] but these conflict with your requirements or minimum-stability.
    - Installation request for nexmo/client (locked at 1.7.0) -> satisfiable by nexmo/client[1.7.0].


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

I'm following the steps in here: https://github.com/Bogardo/Mailgun

Any idea how can I fix this?

This is how my composer.json file looks:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "bogardo/mailgun": "^5.0",
        "fideloper/proxy": "^4.0",
        "intervention/image": "^2.4",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0",
        "stripe/stripe-php": "^6.29"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        },
        "files": ["App/Helpers/Strings.php"]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Gabotronix started a new conversation Using Mailgun API To Send And Receive Mails With Gmail Account?

Hi everybody, I want to start using Mailgun API with laravel instead of using gmail smtp and Mailables as I have been using for my small scale apps so far. Issue is I want the mails to be sent from my gmail account so that if a user replies to my sent mail I or my client can reply back using my gmail account credentials, is it possible to do with Mailgun? the concept of mailgun domains is a bit foreign to me still.

So is it possible to use Mailgun API to send 10.000 mails a month for free but using gmai account for easier managing.

Gabotronix started a new conversation Getting Laravel Data Into Vuex State Without Additional Ajax Request?

Hi everybody, in my apps in order to get global data from laravel into my vue components I had a route middleware where I get global data from my eloquent queries, then I shared this data with my views and passed the data as props into each component, this has proven to work really good so far but can become a bit tricky when I have nested components (one component inside another), obviously I thought having a Globals vuex module would solve this.

I could call a vuex action which could make an ajax request to my global variables endpoint and populate my state each time the vue instance is created but that would mean an extra ajax request to my backend which I generally avoid.

My second idea is having a navbar component which an ajax request to fetch globals on mounted hook, this component would teorically be loaded first and populate my state, not sure if this would work to be honest.

Any ideas?

13 Apr
1 month ago

Gabotronix started a new conversation Vue: Removing Event Listener On Destroy

Hi everybody, I have a vue directed I use in order to apply a fixed class to the inserted DOM element, in order to do this I also attach an event listener to the window object to run when the user scrolls.

My question is, should I remove this event listener when my element is destroyed? I heard the scroll event can affect performance and I'm not sure if the event listener is automatically destroyed each time I refresh a page (my app is not SPA but a laravel app with vue for frontend).

This is my directive:

Vue.directive('scroll-apply-class', {
    isLiteral: true,
    inserted: (el, binding, vnode) => {

        let scrolled = false;
        let stickyTop = 300;

        setTimeout(function(){

            stickyTop = el.offsetTop;

            checkPosition();

            window.addEventListener('scroll', function(e) {
                scrolled = true;
            });

        }, 2500);

        
        let checkPosition = function(){
            if (window.pageYOffset > stickyTop && window.innerWidth > 765) {
                el.classList.add(binding.value)
            }
            else {
                el.classList.remove(binding.value)
            }   
        };


        let timeout = setInterval(function() {
            if (scrolled) {
                scrolled = false;
                checkPosition();
            }
        }, 2500);

    }
});
11 Apr
1 month ago

Gabotronix started a new conversation Issue Using Trait In Markdown Mail Template

Hi everybody, I'm trying to use php Trait method inside my markdown mail template in laravel, problem is I'm getting the following error:

 ErrorException  : Call to undefined method Illuminate\View\Engines\CompilerEngine::getExcerpt() (View: C:\xampp\htdocs\dtcburger.com\resources\views\emails\weekly\weekly-mail-1.blade.php)

I'm trying to use getExcerpt mehod from my Strings php Trait class, but it's not working.

This is my mailable class:

<?php
namespace App\Mail\weekly;


use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Traits\Strings;


class WeeklyMail1 extends Mailable
{
    
    
    use Queueable, SerializesModels;
    use Strings;
    public $mailData;

    
    public function __construct($mailData)
    {
        $this->mailData = $mailData;
    }

    
    public function build()
    {
        $mail = $this->markdown('emails.weekly.weekly-mail-1')
        ->from(env('MAIL_FROM'), env('MAIL_FROM_NAME'))
        ->subject($this->mailData['subject']);

        return $mail;
    }

    
}

@component('mail::message', ['mailData' => $mailData])

{{ $mailData['subject'] }}

@if(count($mailData['events']) > 0)

No te pierdas nuestros próximos eventos

@component('mail::table') | | | | :------------- | :------------- | @foreach($mailData['events'] as $event) | |

{{ $event->title }}

{{!! $this->getExcerpt($event->body, 0, 100) !!}}

| @endforeach @endcomponent @endif

@endcomponent


And my Strings Trait with method getExcerpt inside:
10 Apr
1 month ago

Gabotronix started a new conversation 'confirmationKey' Doesn't Have A Default Value When Registering User

Hi everybody, I'm trying to stablish my custom user verification system, basically I addded a confirmationKey field into my laravel user model, the I changed my register method to add the confirmationKey when an user is created. Issue is for some reason the value isn't added and I'm getting the following error:

SQLSTATE[HY000]: General error: 1364 Field 'confirmationKey' doesn't have a default value (SQL: insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (igyguiiuiug, [email protected], y$HlQbAOyhSCuif5exWZdz/.pCcXAmkWqCdXirNwvY.9/KPDtI5X14S, 2019-04-10 13:26:17, 2019-04-10 13:26:17))

This is pretty weird as you can see in the create method of my RegisterContoller I have added confirmationKey to the create method:

//RegisterController
protected function create(array $data)
    {
        $confirmationKey = Str::random(32);
        //var_dump('confirmationKey: '.$confirmationKey);
        
        $mailData = [
            'confirmationKey' => $confirmationKey,
            'sender' => env('MAIL_FROM'),
            'subject' => 'Confirmación de registro en '.env('APP_NAME'),
        ];

        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'confirmationKey' => $confirmationKey
        ]);

        Mail::to( $data['email'] )->send(new UserMail1($mailData));

        return $user;
    }

what's wrong with my code?

09 Apr
1 month ago

Gabotronix started a new conversation Remove Header From Laravel Markdown Template

Hi everybody, I'm trying to remove the header part from laravel's markdown template but it's not working, I published the files into my vendor folder and all.

This is my message component:

@component('mail::layout')
    {{-- Body --}}
    {{ $slot }}

    {{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                {{ $subcopy }}
            @endcomponent
        @endslot
    @endisset

    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            © {{ date('Y') }} {{ env('APP_NAME') }}.
        @endcomponent
    @endslot
@endcomponent

And my layout file:



{!! strip_tags($slot) !!}
@isset($subcopy)

{!! strip_tags($subcopy) !!}
@endisset

{!! strip_tags($footer) !!}

Any help?

Also, is it possible to make my own markdown template without using default layout? I tried adding laravel markdown components directly into my mail blade.php files but everything lookied like trash and uncentered.

Thanks in advance.

07 Apr
1 month ago

Gabotronix started a new conversation Markdown Mail: Bold Text Inside Markdown Table

Hi everybody, I'm trying to highlight data inside my markdown table for my mail template in laravel, however it's not working... I'm adding a "#" right before my text to no avail.

What I'm doing:

| # {{ $discountcode['unicode'] }} |

This is my full markdown template:

@component('mail::message', ['mailData' => $mailData])
# Disfruta de tu promoción exclusiva en {{ env('APP_NAME') }}

@component('mail::table')
| Descuento | Precio | Código |
| :------------- | :------------- | :-------- |
@foreach($mailData['order']['discountcodes'] as $discountcode)
| {{ $discountcode['discount']['title'] }} | {{ $discountcode['discount']['finalPrice'] }} | # {{ $discountcode['unicode'] }} |
@endforeach
@endcomponent

Saludos,

{{ env('APP_NAME') }}
@endcomponent

04 Apr
1 month ago

Gabotronix started a new conversation Call To A Member Function Count() On Array

Hi everybody, I have an array of strings, I'm trying to get the number of elements in the array but I'm getting the following error:

 Call to a member function count() on array

This is my code:

<?php
namespace App\Models;


use Illuminate\Database\Eloquent\Model;


class Lorem extends Model
{
    

    protected $table = 'pages';
    private static $wordCollection = [
        'Lorem', 'ipsum', 'chief', 'cortana', 'arbiter', 'memento', 'dolor', 'silver', 'gold', 'valar', 'maia',
        'celeborn', 'morgoth', 'instrum', 'redrum', 'wish', 'hachimon', 'kai', 'uchiha', 'senju', 'zetsu'
    ];


    public static function generateLorem($wordsCount = 20){

        $lorem = '';

        if($wordsCount < 100){
            for($i=0; $i<$wordsCount; $i++){
                $word = static::$wordCollection[rand(0, static::$wordCollection->count() - 1)];
                $lorem = $lorem.' '.$word;
            };
        }

        return $lorem;
    }
    
    
}
02 Apr
1 month ago

Gabotronix started a new conversation Good Practices For Pulling From Git Repo Into Production Server

Hi everybody, I have a DigitalOcean VPS with ubuntu and a few laravel projects, for my projects initial setup I do a git clone to create a folder with my application files from my online repository.

I do all development work in my local machine, where I have two branches (master and develop), what I do is merge develop into my local master, then I push from master into my local repository.

Nw back into my production server, when I want to add all the changes added into production I do a git pull from origin, so far this has resulted into git telling me to stash my changes, why is this?

What would be the best approach to pull changes into production server? take in mind that my production server has no working directory perse, all I do in my VPS is either clone or push upgrades into production.