SteveAzz

Experience

50,730

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 501 Lessons Completed
  • 3 Favorites

28th September, 2016

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 5 months ago

@AnotherSamPower You can check my last message, that might help you :)

12th July, 2016

SteveAzz started a new conversation Get Request Information From Promise Or Response Guzzle 6.0 • 8 months ago

I want to get information about the request I have sent, such as url, body sent etc. I am using the Async feature which uses promises (example below)

$client = new \GuzzleHttp\Client();

return  new \GuzzleHttp\Psr7\Request\Request('POST', $this->getUrl(), $this->getHeaders(), $this->getBody());

Is there a way where I can get request information from the promise or from the response?

Reason I am asking this is because I need to store some information about the request in the database later on, which can not be done before I sent the request.

What I tried so far is

Getting the information from the promise with the following methods * $promise->getRequest() * $pomise->Request * $promise->request * $promise->getHandlers() Thank you

9th June, 2016

SteveAzz left a reply on Collection Getting Updated By Reference When I Don't Tell It Too. • 9 months ago

Fixed it by using the clone method first line of the method like the following

  // Get the products for the specified market.
  $markets_products = clone $this->products->get($this->market->name);

SteveAzz started a new conversation Collection Getting Updated By Reference When I Don't Tell It Too. • 9 months ago

Hello, so I have the following collection that looks something like this when I do toArray

"common" => array:21 [
 0 => array:8 [
      "id" => 1
      "field" => "cid"
      "variable" => "CID"
      "description" => "Campaign ID"
      "rule" => null
      "product_id" => 8
      "allowed_values_id" => null
      "common" => 1
    ], ....
]
"product" => array:8 [
 0 => array:8 [
      "id" => 1
      "field" => "cid"
      "variable" => "CID"
      "description" => "Campaign ID"
      "rule" => null
      "product_id" => 8
      "allowed_values_id" => null
      "common" => 1
    ], ....
],
"upsell" => array:2 [
    "PP_HOME_EQUITY" => array:8 [...]
]

Now I have the following snippet that should flatten everything form common, product, and upsell collection, so for example

 0 => array:8 [
    "id" => 1
    "field" => "cid"
    "variable" => "CID"
    "description" => "Campaign ID"
    "rule" => null
    "product_id" => 8
    "allowed_values_id" => null
    "common" => 1
  ]
  1 => array:8 [
    "id" => 2
    "field" => "sid"
    "variable" => "SID"
    "description" => "Tracking Key"
    "rule" => null
    "product_id" => 8
    "allowed_values_id" => null
    "common" => 1
  ]

Now my issue is that the fist collection, the un parsed one is getting updated as well when I don't want it to be. The snippet that is parseing everything is the following.

// Get the products for the specified market.
$markets_products = $this->products->get($this->market->name);

// Remove the only_upsell since it is just a boolean
$markets_products->offsetUnset('only_upsell');

// Flatten the upsell collection to be just one thing.
$markets_products->offsetSet('upsell', $markets_products->get('upsell')->flatten(1));

// Flatten everything to remove an nesting
return $markets_products->flatten(1);

25th May, 2016

SteveAzz started a new conversation Validating JSON Schema Structure • 9 months ago

So I have build the follow custom validation rule in Laravel 5.2 and wanted to ask for your opinion if I can improve it in any way. Basicly what the validation rule is doing it is checking is the json that is sent is in the correct schema. I only need this to validate one field from the post data.

Validator::extend('ping', function ($attributes, $value, $parameters, $validator) {
    $valid_json = [
        'market_id' => ':id',
        'ping' => [
            'ping_id' => ':ping_id',
            'status' => ':status',
            'commission' => ':commission',
            'tracking' => []
        ],
    ];

    $json = json_decode($value, true);

    
    return (!count(array_diff_key($valid_json, $json))) && (!count(array_diff_key($valid_json['ping'], $json['ping'])));

11th March, 2016

SteveAzz left a reply on How Can I Remove All These If Conditions • 1 year ago

hmm thanks for the feedback, ill keep on diging. Thank you

SteveAzz left a reply on How Can I Remove All These If Conditions • 1 year ago

Thats the only code the class has, my understand of it so far is checking if there is any redirect on the url that it is currently on if there is write the changes to the database.

SteveAzz left a reply on How Can I Remove All These If Conditions • 1 year ago

@shez1983 Thing is im not even sure what it does, I don't know why all of the checks are there just maybe you guys had an idea to reduce that amount of checks.

SteveAzz started a new conversation How Can I Remove All These If Conditions • 1 year ago

So today I came across a peace of code and was wondering how would you refactor such a thing. Would love some input.

        if ($this->owner->PageID)
        {
            $DestinationURLSegment = $this->owner->Page()->URLSegment;
            if ($DestinationURLSegment)
            {
                $RedirectURL = RedirectedURL::get()->find('FromBase', '/'.$DestinationURLSegment);
                if ($RedirectURL)
                {
                    $RedirectToPage = SiteTree::get()->find('URLSegment', ltrim($RedirectURL->To, '/'));
                    if ($RedirectToPage)
                    {
                        $this->owner->PageID = $RedirectToPage->ID;
                        $this->owner->flushCache();
                        if ($write)
                        {
                            $this->owner->write();
                        }
                    }
                }
            }
        }

3rd February, 2016

SteveAzz left a reply on Vue Input Masks • 1 year ago

I would greatly appricate, I coudn't find anything else.

SteveAzz left a reply on Vue Input Masks • 1 year ago

When i run npm install all i get is '.npmignore' 'package.json' 'README.md' no js file what so ever.

SteveAzz started a new conversation Vue Input Masks • 1 year ago

I want to have an input mask on a specific input where it parses the use input into a human readable US phnome number.

For example

User enter: 1231231234 User sees: (123)-123-1234

Is there a way I can do this? I have tried with filters but didn't have much success

Filter:

Vue.filter 'phone', (value) ->
    return value.replace(/^([0-9]{3})([0-9]{3})([0-9]{4})$/, '($1)-$2-$3')

25th January, 2016

SteveAzz left a reply on Am I Doing This Registration The Best Way? • 1 year ago

@jefferyway any good recourses on application service classes? Cant seem to find and simple ones

SteveAzz left a reply on Am I Doing This Registration The Best Way? • 1 year ago

Okay got ya, ill give it another go.

SteveAzz left a reply on Am I Doing This Registration The Best Way? • 1 year ago

@JeffreyWay Will a repository maybe fix the issue or do you suggest something else?

SteveAzz left a reply on Am I Doing This Registration The Best Way? • 1 year ago

hmmm don't know why repositories didn't come to mind, I will take a look at those thank you. If any other come to mind please tell me.

SteveAzz started a new conversation Am I Doing This Registration The Best Way? • 1 year ago

I have a form where it takes the following information.

  • email
  • password
  • password_confirmation
  • business_name
  • business_type
  • business_location

Now in the controller I have the following

public function store(Request $request)
{
    $this->validate($request, [
        'email'                 => 'required|email|unique:users',
        'password'              => 'required',
        'password_confirmation' => 'required',
        'business_name'         => 'required|unique:businesses,name',
        'business_address'      => 'required',
        'business_type'         => 'array'
    ]);

    // Registers a new business
    Business::register($request);

    // Redirect to dashboard
    return redirect('/dashboard');
}

And inside of Business::register I have the following code

public static function register($request)
{
    // Merging business name as username
    $request->merge(['name' => 'steve']);

    // Create user
    $auth_controller = new AuthController();
    $auth_controller->register($request);

    // Create business
    $business = Business::create([
        'id'               => Uuid::generate()->string,
        'name'             => $request->input('business_name'),
        'business_address' => $request->input('business_address')
    ]);

    // Create business type relationship
    $business->businessTypes()->sync($request->input('business_type'));
}

Business::class is the model which is extending eloquent.

My real question is is it okay to call a static function inside the model and call a controller to use the laravel registration process for the user?

24th January, 2016

SteveAzz left a reply on Database Migration Not Working For Recursive Relationship. • 1 year ago

Found the issue I was not adding a primary key constrain to the uuid the migration looks like this now

Schema::create('business_types', function (Blueprint $table) {
    $table->uuid('id');
    $table->string('name');
    $table->uuid('parent_id')->nullable();
    $table->timestamps();

    $table->primary('id');
    $table->foreign('parent_id')->references('id')->on('business_types');
});

SteveAzz started a new conversation Database Migration Not Working For Recursive Relationship. • 1 year ago

I have the following migration

Schema::create('business_types', function (Blueprint $table) {
    $table->uuid('id')->unique();
    $table->string('name');
    $table->uuid('parent_id')->nullable();
    $table->timestamps();

    $table->foreign('parent_id')->references('id')->on('business_types');
});

When I run the migration I get the following error.

'errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table business_types add constraint business_types_parent_id_foreign foreign key (parent_id) references
business_types (id)'

Now when I comment the foreign key migration and run that EXACT QUERY in the console the foreign key is added successfully. What can be the problem that I am not seeing?

16th January, 2016

SteveAzz left a reply on Redis Error • 1 year ago

Well the application works on redis. If you remove it the application wont work how originally indented

6th January, 2016

SteveAzz left a reply on Vue Cli • 1 year ago

Okay found it! Needs to go something like this

methods: {
    greetUser: function (event) {
      console.log('Hello')
    }
  }

SteveAzz started a new conversation Vue Cli • 1 year ago

So I kinda understand the basics of vue right now, and wish to go a littile bit further and decided to install the vue-cli tool and create a new project with it.

So far so good, it comes out with a component like this

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // note: changing this line won't causes changes
      // with hot-reload because the reloaded component
      // preserves its current state and we are modifying
      // its initial state.
      msg: 'Hello !'
    }
  }
}
</script>

And I wanted to a an event on click so I added the following.

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <button v-on:click="greetUser">Greet</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // note: changing this line won't causes changes
      // with hot-reload because the reloaded component
      // preserves its current state and we are modifying
      // its initial state.
      msg: 'Hello !'
    }
  },

  methods () {
    return {
      greetUser: function (event) {
        console.log('Hello')
      }
    }
  }
}
</script>

Now this doesn't work and when I check the console it gives me the following working

[Vue warn]: v-on:click="greetUser" expects a function value, got undefined

What could be the problem please?

SteveAzz started a new conversation Possible Bug Maybe? • 1 year ago

So I go to the following forum thread https://laracasts.com/discuss/channels/laravel/laravel-42-and-php-7

And I see the following in my browsers.

http://imgur.com/YmXZBXQ

3rd January, 2016

SteveAzz left a reply on Aws Sdk With Lumen • 1 year ago

What kind of problems are you facing? Go into more detail to get a faster/better response.

27th December, 2015

SteveAzz left a reply on Homestead Took One. • 1 year ago

First thing you need to do is run the make command which will create a yaml file and vagrant file in the root of the project.

After that you will have to run vagrant up and a new vm will be created.

Be aware that like this homestead will only host one project.

24th December, 2015

SteveAzz left a reply on Console Commands • 1 year ago

@zachleigh I was goin to do that but since I will be creating classes just like laravel, different template I tought Id just use his wrapper around it, was worth the try. Thank you for your response.

SteveAzz started a new conversation Console Commands • 1 year ago

So I want to create my own "artisan" replication outside of the framework for a personal project.

I decided to pull in the "illuminate/console" package from composer so that I get most of the generators from laravel as possible.

Here is the class that I created so far.

http://laravel.io/bin/REr7X

and composer.json file looks something like the following.

{
    "require": {
        "laravel/homestead": "^3.0",
        "illuminate/console": "^5.2",
        "illuminate/filesystem": "^5.2"
    },
    "autoload": {
        "psr-4": {
            "Mortgageloan\\": "src"
        }
    },
    "require-dev": {
        "phpunit/phpunit": "^5.1"
    }
}

Now when I try to run the command I get the following error.

PHP Fatal error:  Uncaught Error: Call to a member function call() on null in /home/steve/Code/work/ml/commands/vendor/illuminate/console/Command.php:169
Stack trace:
#0 /home/steve/Code/work/ml/commands/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /home/steve/Code/work/ml/commands/vendor/illuminate/console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /home/steve/Code/work/ml/commands/vendor/symfony/console/Application.php(788): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/steve/Code/work/ml/commands/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Mortgageloan\WidgetMakeCommand), Object(Symfony\C in /home/steve/Code/work/ml/commands/vendor/illuminate/console/Command.php on line 169

Is it possible I am missing something? Thank you.

20th December, 2015

SteveAzz started a new conversation Enable Strict_types Porject Wide In Laravel. • 1 year ago

So I started playing with php7 and with its strict type hinting and I have to do

declare(strict_types=1);

In every class that i want to use strict type hiniting. My question is there a way how to make it take effect in everything?

Files that I have tried : *bootstrap/app.php *bootstrap/autoload.php *public/index.php

None of above worked.

17th November, 2015

SteveAzz left a reply on Laraval Breaks From Time To Time? • 1 year ago

What kind a "breaking" is happening? Is it happening on one specific page? Give more detail please on what kind of environment you are running on and so on.

7th November, 2015

SteveAzz left a reply on Docker • 1 year ago

So following this I have created my own package to dockerize your laravel application. It can be found right here : https://github.com/SteveAzz/laravel-docker

1st October, 2015

SteveAzz left a reply on Homestead On El Captain Error • 1 year ago

failed to open /dev/vboxnetctl: No such file or directory You could try re installing vmbox to fix that.

SteveAzz left a reply on Homestead On El Captain Error • 1 year ago

Have you tried any other vagrant boxes?

16th August, 2015

SteveAzz left a reply on Docker • 1 year ago

You are not understanding my point, you will have the same mysql version for example on both dev and production using the same container that allowd for automation and all of the CI goodness.

15th August, 2015

SteveAzz left a reply on Docker • 1 year ago

@Istables Thing is you can take those container for production as well having less issues when you deploy into production. That is why i really want to get into it.

12th August, 2015

SteveAzz left a reply on Composer Require Laravel/homestead Doesn't Work • 1 year ago

hmmm this seems to be system specific. On windows it works but on ubuntu 14.04 it still gives me that error. Does anyone have any idea why this can be? Other stuff is saved in the bin folder such as phpunit and phpspec. I don't know what is causing this.

SteveAzz left a reply on Composer Require Laravel/homestead Doesn't Work • 1 year ago

@bobbybouwmann Will do, when I get home from work. Will keep you posted!

SteveAzz left a reply on Composer Require Laravel/homestead Doesn't Work • 1 year ago

@bobbybouwmann I know that but they had realsed a package for homestead per project. Was that removed?

11th August, 2015

SteveAzz started a new conversation Composer Require Laravel/homestead Doesn't Work • 1 year ago

So I was going to start a new project and started setting up me dependcies. I ran the following command composer require laravel/homestead but I get the following errror "Skipped installation of bin homestead for package laravel/homestead: file not found in package".

Now I did composer self-update, also did a composer diagnose and everything is OK.

My set up is ubuntu 14.04 with latest updates. If anyone has some insite please tell me.

18th June, 2015

SteveAzz left a reply on How To Create This Model Factory. ( Laravel 5.1) • 1 year ago

@RachidLaasri That is much better! Thank you :)

SteveAzz left a reply on How To Create This Model Factory. ( Laravel 5.1) • 1 year ago

@phildawson I get the following error when I do like you showed I get the following error.

UnexpectedValueException in Response.php line 403:
The Response content must be a string or object implementing __toString(), "object" given.

SteveAzz started a new conversation How To Create This Model Factory. ( Laravel 5.1) • 1 year ago

I have the follow database structure

User

  • id
  • name
  • ...

Post

  • id
  • title
  • body
  • user_id (fk)

Vote

  • id
  • type
  • user_id (fk)
  • post_id (fk)

Now I have set up the relationships between the model like the following which should be correct.

User

/**
     * Retrieves all of the posts associated with the user.
     *
     * @return \Illumainte\Database\Relations\HasMany
     */
    public function posts()
    {
        return $this->hasMany('Reddit\Post');
    }

    /**
     * Retreives all of the votes assoicated with the user.
     * 
     * @return \Illuminate\Database\Relations\HasMany
     */
    public function vote()
    {
        return $this->hasMany('Reddit\Vote');
    }

Post

**
     * Retrieves the user associated with the post.
     *
     * @return \Illuminate\Database\Relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo('Reddit\User');
    }

    /**
     * Retrieves the votes associated with the post.
     * @return \Illuminate\Database\Relation\HasMany
     */
    public function votes()
    {
        return $this->hasMany('Reddit\Vote');
    }

Vote

/**
     * Retrieves the post associated with the vote.
     *
     * @return \Illuminate\Database\Relation\BelongsTo
     */
    public function post()
    {
        return $this->belongsTo('Reddit\Post');
    }

    /**
     * Retrieves the user associated with the vote.
     *
     * @return \Illuminate\Database\Relation\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo('Reddit\User');
    }

Now I manged to create the Model factory for the Post by following the documentation, but I am having trouble on how to do for the Vote where it requires two foreign keys. If you need any more information please ask.

1st June, 2015

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

I have figured it out! I overriding the SetUp method so I can log in and it apperly is brakes the submitForm method. Weird stuff...

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

 {!! Form::model($post, ['method' => 'PATCH', 'action' => ['PostsController@update', $post->id]]) !!}
        @include('posts.form', ['submitButton' => 'Update Post'])
    {!! Form::close() !!}

I think is something wrong with my test, because in the browser it works perfectly.

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

@mstnorris The tag is optinal. I was using the test dummy but it was still failing so i dicded to hard code the values just in case something was wrong with testdummy

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

<!-- title From Input -->
<div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
        {!! Form::label('title', 'Enter the title of the post:') !!}
        {!! Form::text('title', null, ['class' => 'form-control', 'placeholder' => 'Enter the title of the post']) !!}
    </div>
</div>

<!-- body From Input -->
<div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
        {!! Form::label('body', 'Enter the body of the post:') !!}
        {!! Form::textarea('body', null, ['class' => 'form-control', 'rows' => '20' , 'placeholder' => 'Enter the body of the post']) !!}
    </div>
</div>

<!-- tagsList From Input -->
<div class="row control-group">
    <div class="form-group col-xs-12 floating-label-form-group controls">
        {!! Form::label('tagList', 'Select an Option:') !!}
        {!! Form::select('tagList[]', $tags, null, ['id' => 'tags', 'class' => 'form-control', 'multiple']) !!}
    </div>
</div><br/>

<!-- Submit Button -->
<div class="row">
    <div class="form-group col-xs-12">
        {!! Form::submit($submitButton, ['class' => 'btn btn-default']) !!}
    </div>
</div>

SteveAzz left a reply on Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

My test fials when i add the "SubmitForm" method other than that it works. I dont know why it is failing in the test but in the browser it works.

SteveAzz started a new conversation Test Doesn't Work But In Browser It Work. Laravel 5 & Laracasts\Integrated • 1 year ago

I have the following test.

    public function it_updates_post()
    {
        $post = TestDummy::create('Blog\Post');
        $newPost = ['title' => 'Some title', 'body' => 'The body'];


        $this->visit('posts/' . $post->id . '/edit')
            ->seePageIs('posts/' . $post->id . '/edit')
            ->see('Edit Post')
            ->submitForm('Update Post', $newPost);
    }

When I run the test it goes me the following error `A GET request to 'http://localhost/posts/218' failed. Got a 405 code instead.

MethodNotAllowedHttpException on RouteCollection.php line 207 `

When I try and update a post inside of the browser it works as intended. What can be causing this?

28th May, 2015

SteveAzz left a reply on PHPStorm Importing Namespaces With Aliases • 1 year ago

I think something you can do is create a live template. When you write log it will automatically import the namespace.

https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/7

SteveAzz left a reply on Build Your First App - Importing Mail • 1 year ago

Mine is use Illuminate\Support\Facades\Mail Since he is using the Mail facade.

Edit Your Profile
Update

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