Riotsmurf

Experience

860

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 6 Lessons Completed
  • 0 Favorites

13th September, 2017

Riotsmurf left a reply on Component Events In Vue • 1 month ago

@andonovn Thank you very much for coming back and explaining this. Helped a lot.

11th September, 2017

Riotsmurf left a reply on Component Events In Vue • 1 month ago

@andonovn What if i wanted it to override the templates testMethod() with the new Vue({methods:{ testMethod(){ console.log('Some different than normal stuff'); } }})

8th September, 2017

Riotsmurf started a new conversation Component Events In Vue • 1 month ago

I am having a problem binding events to elements in my vue component. I will give an example of my issue and maybe someone can help me out.

I have a file called test.vue and it has

<template>
  <div class="box">
    <div class="button" v-on:click="testMethod">Do something</div>
     <div class="box">
         <div class="columns">
             <div class="column">Column 1</div>
             <div class="column">Column 2</div>
             <div class="column">Column 3</div>
             <div class="column">Column 4</div>
             <div class="column">Column 5</div>
         </div>
       </div>
  </div>    
</template>

I have a javascript file called test.js that has

window.Vue = require('vue');

(function(){

    Vue.component('my-test', require('./components/test.vue'));
    new Vue({
        el: '#test',
        created: function() {
            console.log('Starting the testarino');
        }
        methods :{
            testMethod: function(){
               console.log("I did something yay!!");
            }
        }
    });
}());

my blade template looks like this

{{--Extend base layout--}}
@extends('layouts.app')

{{--Links and scripts--}}
@section('scripts')
  <script src="{{asset('js/test.js')}}" ></script>
@endsection

{{--Content--}}
@section('content')
  <div id="test">
    <my-test></my-test>
  </div>
@endsection

When i load the page i get this error in the console

[Vue warn]: Property or method "testMethod" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

found in

---> <MyTest> at /var/www/html/resources/assets/js/components/test.vue
       <Root>
warn @ test.js:951
warnNonPresent @ test.js:2106
get @ test.js:2147
render @ test.js:404
Vue._render @ test.js:4600
updateComponent @ test.js:3010
get @ test.js:3353
Watcher @ test.js:3342
mountComponent @ test.js:3014
Vue$3.$mount @ test.js:8335
Vue$3.$mount @ test.js:10538
init @ test.js:3973
createComponent @ test.js:5619
createElm @ test.js:5562
createChildren @ test.js:5690
createElm @ test.js:5595
patch @ test.js:6078
Vue._update @ test.js:2886
updateComponent @ test.js:3010
get @ test.js:3353
Watcher @ test.js:3342
mountComponent @ test.js:3014
Vue$3.$mount @ test.js:8335
Vue$3.$mount @ test.js:10538
Vue._init @ test.js:4708
Vue$3 @ test.js:4793
(anonymous) @ test.js:92
module.exports @ test.js:105
__webpack_require__ @ test.js:20
(anonymous) @ test.js:10592
__webpack_require__ @ test.js:20
(anonymous) @ test.js:66
(anonymous) @ test.js:69
test.js:951 [Vue warn]: Invalid handler for event "click": got undefined

found in

---> <MyTest> at /var/www/html/resources/assets/js/components/test.vue
       <Root>

27th June, 2017

Riotsmurf left a reply on SMTP Mail Fail • 3 months ago

If you don't get the solution, i recommend switching to mailgun.

Riotsmurf started a new conversation Validation Of An Array And Custom Message. Help Me! • 3 months ago

I want to validate an array of emails and then tell the user which of those emails failed the validation.

How would i grab the index of the failed email? I tried something like this: but failed(I knew it would)

private function validator($data)
    {
        $rules = [
              'custom' => [
                'to.*' =>[
                  'email' => $data['to']['*'] . " is not a valid email.",
                  'required' => "This requires an email address to send."
                ],
                'bcc.*' => [
                  'email' => $data['bcc']['*'] . " is not a valid email."
                ],
              ],
              'content' => 'min:4',
          ];

          return Validator::make($data, $rules);
    }

I want to know how i can get the index where the little * is in $data['bcc'] and $data['to'].

If i have to make a custom validator that loops through and validates each email individually then fine, but i would like something short and easy here if possible.

15th June, 2017

Riotsmurf left a reply on Lumen Not Seeing Js Folder/files In Public. But Can See Css. • 4 months ago

RaphaelBronsveld: Omfg. My brain is dead. Thanks! I cannot believe i did that.

Riotsmurf started a new conversation Lumen Not Seeing Js Folder/files In Public. But Can See Css. • 4 months ago

I have a public folder with css and js folders in it. Inside the css folder is a bulma.css file. In the js folder there is a searchInit.js file. When i try to bring these in via link/script tags it just ignores the js ones.

My html looks like this:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>{{ config('app.name', 'Conan: ') }} @yield('title')</title>

    <!-- Styles -->
    <link href="/css/bulma.css" rel="stylesheet" type="text/css" />

    {{-- <link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.2/css/bulma.css" rel="stylesheet" type="text/css" /> --}}

    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

    @yield('css_links')

</head>

<body>

    <div id="app">
       
        @include('partials/header')

        <div class="columns">

            <div class="column is-one-quarter">
           
                @yield('sidebar')

            </div>
            
            <div class="column is-three-quarters">

                @yield('content')

            </div>

        </div>

        @include('partials/footer')

    </div>


    <script href="/js/list.js" type="text/javascript"></script>
    <script href="/js/searchInit.js" type="text/javascript"></script>
</body>

</html>

When i load the page this is what the src looks like: http://i.imgur.com/08b9v48.png

What i don't understand is why is it ignoring the js folder/files. Even when i move a js file into the css folder, it still doesn't see it. I have no way of diagnosing this problem because i never had it before and i have not found my problem through the googlez.

14th June, 2017

Riotsmurf left a reply on Am I Doing This Right? • 4 months ago

Snapey: Hmm i see what you mean.

We had a database idea at first but then felt like we didn't want to store this information because its just requirements that are set by the state. We felt like the law does not change enough, and if it did it would not be a big deal to go into the FlowerMixTypeTest class and set the $requiredTests variable to what it would require. Then commit, push, and merge. Would you consider this bad still?

I suppose it would be about which is faster/easier for the system. Whether it is easier to store and update this information in the database, or less time to change 1 class.

Riotsmurf left a reply on Am I Doing This Right? • 4 months ago

jlrdw: This is a select, not a checkbox or radio button. there are 6 parent types. VegetationType, ExtractType, TopicalType etc. I am not going to force the users to select "Flower" or "Flower Mix" and then check a radio button to pick vegetation because it leaves too much room for user error. This does not answer my question.

13th June, 2017

Riotsmurf started a new conversation Am I Breaking The O. Rule In S.O.L.I.D. ? • 4 months ago

I am creating business logic in my Laravel project. I am creating an order and adding samples to the order. Each sample( depending on its type ) has a set of tests that it requires by law so i made this.

So i use getTestCollection() to return tests a product type needs.

<?php

namespace App\TestLogic;

class Product
{

    private $type;
    private $typeFactory;

    //Set base test as potency. Potency->id = 6
    public $tests = [
            "Foreign Matter" => 0,
            "Microbial" => 0,
            "Moisture" => 0,
            "Mycotoxin" => 0,
            "Pesticide Residue" => 0,
            "Potency" => 0,
            "Residual Solvent" => 0,
            "Terpenes" => 0,
            "Water Activity" => 0
    ];

    public function __construct(ProductTypeFactory $typeFactory)
    {
        $this->typeFactory = $typeFactory;
    }
    /**
     * Gets a collection of tests based on the type of this product
     * @return Array Array of tests required by type.
     */
    public function getTestCollection()
    {
        $classType = str_replace(' ', '',$this->type);
        $productType = $this->typeFactory->getProductTestType($classType);

        return $productType->getTestCollection($this);
    }

    public function setType($type)
    {
        $this->type = $type;
    }

    public function getType()
    {
        return $this->type;
    }
}

There are some types that require the same set of tests like, Flower and Flower Mix. So i made this.

<?php

namespace App\TestLogic;

class VegetationType implements IproductTypeTest
{
    protected $requiredTests = [
            "Moisture" => 1,
            "Water Activity" => 1,
            "Potency" => 1,
            "Foreign Matter" => 1,
            "Microbial" => 1
            // "Mycotoxins"
    ];

    public function getTestCollection(Product $product)
    {
        foreach ($this->requiredTests as $key => $rTest) {
                $product->tests[$key]+=$rTest;
        }
        return $product->tests;
    }
}

And my Flower, Flower Mix classes extend this. So now they are empty like this.

<?php

namespace App\TestLogic;

class FlowerMixTypeTest extends VegetationType
{
}

<?php

namespace App\TestLogic;

class FlowerTypeTest extends VegetationType
{
}

Should VegitationType be a trait and not a class? This is my first go at this and i have a feeling its a little weird...

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.