pstephan1187

pstephan1187

Member Since 5 Years Ago

St Louis, MO

Senior Developer at BluSolutions

Experience Points 24,830
Experience Level 5

170 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 261
Lessons
Completed
Best Reply Awards 13
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

28 Oct
2 years ago

pstephan1187 started a new conversation Vue File Produces Fragment When Using Template Tag

I am using elixir to compile down a .vue file into an ES5 file. It works fine whenever I have the file setup like below:

<script>
module.exports = {
    template: '<div><pre>Some text {{ msg }}</pre></div>',
    data: function(){return {
        msg: 'is testing here'
    }}
}
</script>

But whenever I set it up like below, the template doesn't render, and the Vue Dev Tools mark the component as a fragment:

<template>
    <div><pre>Some text {{ msg }}</pre></div>
</template>
<script>
module.exports = {
    // template: '<div><pre>Some text {{ msg }}</pre></div>',
    data: function(){return {
        msg: 'is testing here'
    }}
}
</script>

Everything is exactly the same. Here are my files:

gulpfile:

var elixir = require('laravel-elixir');

require('laravel-elixir-vue-2');

elixir(function(mix) {
    mix.webpack('./src/es5.js', './dist/vuejs-datatable.js');
});

es5.js

window.Vue.component('datatable', require('./vue-datatable.vue'));

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Examples</title>

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  </head>
  <body>

    <datatable></datatable>
    
    <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.28/vue.js"></script>
    <script src="../../dist/vuejs-datatable.js"></script>
    <script src="app.js"></script>
  </body>
</html>

app.js

Vue.config.debug = true;
Vue.config.devtools = true;

vm = new Vue({
    el: 'body',
    data: {
        columns: [
            {label: 'ID', field: 'id', align: 'center'},
            {label: 'Username', field: 'username'},
            {label: 'First Name', field: 'first_name'},
            {label: 'Last Name', field: 'last_name'},
            {label: 'Email', field: 'email', align: 'right'},
            {label: 'Address', callback: function(row){
                return row.address + ', ' + row.city + ', ' + row.state;
            }, align: 'right'}
        ],
        rows: [
            {
              "id": 1,
              "username": "dprice0",
              "first_name": "Daniel",
              "last_name": "Price",
              "email": "dprice0@blogs.com",
              "address": "3 Toban Park",
              "city": "Pocatello",
              "state": "Idaho"
            }
        ]
    }
});

Anyone have any ideas on what is going on?

13 May
3 years ago

pstephan1187 left a reply on Don't Force Team Registration

Extend the original CreateUser class and override the validator method. Then in your AppServiceProviders register method, add this line:

app()->bind('Laravel\Spark\Contracts\Interactions\Auth\CreateUser', YourNewCreateUserClass::class, true);

This won't keep the team from being created, but will in actuality create a nameless team.

23 Mar
3 years ago

pstephan1187 left a reply on PHP-PM And Laravel

I saw the same thing and was thinking it would make a great tutorial as well. would love to see how to implement this in production (or development for that matter)

21 Mar
3 years ago

pstephan1187 left a reply on Amazon S3 Access Denied When Accessing Files

You need to set the ACL for the file to 'public'

10 Mar
3 years ago

pstephan1187 left a reply on Vuejs Vs Angularjs

I have used both Angular 1 and Vue. Both are great frameworks and treat you well, though Vue is simpler, easier to understand and just as powerful. I enjoy using Vue more than I enjoy using Angular. It results in code that is easier to read and projects that are faster to complete.

29 Feb
3 years ago

pstephan1187 left a reply on Adding "name" Attribute To VueJS Bound Form Input

@infernobass7, it seems that it works fine in a fiddle. Must be something deeper in my code. ugh

pstephan1187 started a new conversation Adding "name" Attribute To VueJS Bound Form Input

I have the following form:

<form id="edmunds-trade-in-form" method="post">
    
    <div class="row">
        
        
        <div class="col-sm-6">
            <h3>Contact Information</h3>
            
            <div class="form-group">
                <label for="cfName"><span class="req">*</span>Full Name</label>
                <input id="cfName" class="text" name="name" type="text" />
            </div>
            
            <div class="form-group">
                <label for="cfEmail"><span class="req">*</span>Email Address</label>
                <input id="cfEmail" class="text" name="email" type="text" />
            </div>
            
            <div class="form-group">
                <label for="cfStreet">Street</label>
                <input id="cfStreet" class="text" name="street1" type="text" />
            </div>
            
            <div class="form-group">
                <label for="cfCity">City</label>
                <input id="cfCity" class="text" name="city" type="text" />
            </div>
            
            <div class="form-group">
                <label for="cfState">State</label>
                <select id="cfState" name="state">
                    <option value="" selected="selected">Select a State</option> 
                    <option value="AL">Alabama</option> 
                    <option value="AK">Alaska</option> 
                    <option value="AZ">Arizona</option> 
                    <option value="AR">Arkansas</option> 
                    <option value="CA">California</option> 
                    <option value="CO">Colorado</option> 
                    <option value="CT">Connecticut</option> 
                    <option value="DE">Delaware</option> 
                    <option value="DC">District Of Columbia</option> 
                    <option value="FL">Florida</option> 
                    <option value="GA">Georgia</option> 
                    <option value="HI">Hawaii</option> 
                    <option value="ID">Idaho</option> 
                    <option value="IL">Illinois</option> 
                    <option value="IN">Indiana</option> 
                    <option value="IA">Iowa</option> 
                    <option value="KS">Kansas</option> 
                    <option value="KY">Kentucky</option> 
                    <option value="LA">Louisiana</option> 
                    <option value="ME">Maine</option> 
                    <option value="MD">Maryland</option> 
                    <option value="MA">Massachusetts</option> 
                    <option value="MI">Michigan</option> 
                    <option value="MN">Minnesota</option> 
                    <option value="MS">Mississippi</option> 
                    <option value="MO">Missouri</option> 
                    <option value="MT">Montana</option> 
                    <option value="NE">Nebraska</option> 
                    <option value="NV">Nevada</option> 
                    <option value="NH">New Hampshire</option> 
                    <option value="NJ">New Jersey</option> 
                    <option value="NM">New Mexico</option> 
                    <option value="NY">New York</option> 
                    <option value="NC">North Carolina</option> 
                    <option value="ND">North Dakota</option> 
                    <option value="OH">Ohio</option> 
                    <option value="OK">Oklahoma</option> 
                    <option value="OR">Oregon</option> 
                    <option value="PA">Pennsylvania</option> 
                    <option value="RI">Rhode Island</option> 
                    <option value="SC">South Carolina</option> 
                    <option value="SD">South Dakota</option> 
                    <option value="TN">Tennessee</option> 
                    <option value="TX">Texas</option> 
                    <option value="UT">Utah</option> 
                    <option value="VT">Vermont</option> 
                    <option value="VA">Virginia</option> 
                    <option value="WA">Washington</option> 
                    <option value="WV">West Virginia</option> 
                    <option value="WI">Wisconsin</option> 
                    <option value="WY">Wyoming</option>
                    <option value="Outside_USA">Outside US</option>
                </select>
            </div>
            
            <div class="form-group">
                <label for="cfPhone"><span class="req">*</span>Phone</label>
                <input id="cfPhone" class="text" name="phone" type="text" />
            </div>
            
            <div class="form-group">
                <label for="cfPref"><span class="req">*</span>Preferred Contact</label>
                <select id="cfPref" name="pref">
                    <option value="email">Email</option>
                    <option value="cell">Phone</option>
                </select>
            </div>
            
            <div class="form-group">
                <label>Message:</label>
                <textarea id="other_info" rows="10" name="message"></textarea>
            </div>
        </div>
        
        
        <div class="col-sm-6">
            <h3>Vehicle Information</h3>
            
            <div class="form-group">
                <label>Year</label>
                <input type="number" class="form-control" v-model="trade.year" @change="changeYear()" min="1990" max="2016" />
            </div>
            
            <div class="form-group">
                <label>Make</label>
                <select v-model="trade.make" class="form-control" name="make" @change="changeMake()">
                    <option v-for="make in makes" :value="make.niceName">${make.name}</option>
                </select>
            </div>
            
            <div class="form-group">
                <label>Model</label>
                <select v-model="trade.model" class="form-control" name="model" @change="changeModel()">
                    <option v-for="model in models" :value="model.niceName">${model.name}</option>
                </select>
            </div>
            
            <div class="form-group">
                <label>Style</label>
                <select v-model="trade.style" class="form-control" name="style" @change="getTradeInValue()">
                    <option v-for="style in styles" :value="style.name">${style.name}</option>
                </select>
            </div>
            
            <div class="form-group">
                <label>Mileage</label>
                <input type="number" class="form-control" v-model="trade.mileage" name="mileage" @change="getTradeInValue()" />
            </div>
            
            <div class="form-group">
                <label>ZIP</label>
                <input type="number" class="form-control" v-model="trade.zip" name="zip" @change="getTradeInValue()" />
            </div>
            
            <div class="form-group">
                <label>Trade In Value</label>
                <div class="input-group">
                    <span class="input-group-addon">$</span>
                    <input type="number" class="form-control" name="trade-in-value" v-model="trade.value" readonly/>
                </div>
            </div>
            
            <input class="btn btn-primary" type="submit" value="Submit" />
        </div>
        
        
    </div>
                
                
</form>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-resource/0.7.0/vue-resource.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript"> 
var edmunds_trade_form = new Vue({
    el: '#edmunds-trade-in-form',
    data: {
        edmunds_key: 'XXXXXXXXXXXXXXXXXXX',
        trade: {
            year: 2011,
            make:null,
            model:null,
            style:null,
            mileage:null,
            zip:null,
            value: 0
        },
        make: null,
        makes: [],
        models: [],
        styles: []
    },
    methods: {
        changeYear: function(){
            var url = 'http://api.edmunds.com/api/vehicle/v2/makes?year='+this.trade.year+'&view=basic&fmt=json&api_key='+this.edmunds_key;
            
            this.$http.get(url).then(function(response){
                this.makes = response.data.makes;
                this.make = null;
                this.models = [];
                this.styles = [];

                this.trade.make = null;
                this.trade.model = null;
                this.trade.style = null;
                this.trade.value = 0;
            });
        },
        changeMake: function(){
            for(var i in this.makes){
                var make = this.makes[i];
                if(make.niceName == this.trade.make){
                    this.make = make;
                }
            }
            
            this.models = this.make.models
            this.styles = [];

            this.trade.model = null;
            this.trade.style = null;
            this.trade.value = 0
        },
        changeModel: function(){
            var url = 'http://api.edmunds.com/api/vehicle/v2/'+this.trade.make+'/'+this.trade.model+'/'+this.trade.year+'/styles?view=basic&fmt=json&api_key='+this.edmunds_key;
            
            this.$http.get(url).then(function(response){
                this.styles = response.data.styles

                this.trade.style = null;
                this.trade.value = 0
            });
        },
        getTradeInValue: function(){            
            if(!(this.trade.style && this.trade.mileage && this.trade.zip)){
                return;
            }
            
            var style_id = null;
            
            for(var i in this.styles){
                var style = this.styles[i];
                if(style.name == this.trade.style){
                    style_id = style.id;
                }
            }
            
            var url = 'http://api.edmunds.com/v1/api/tmv/tmvservice/calculateusedtmv?styleid='+style_id+'&condition=Outstanding&mileage='+this.trade.mileage+'&zip='+this.trade.zip+'&fmt=json&api_key='+this.edmunds_key;
            
            this.$http.get(url).then(function(response){
                this.trade.value = response.data.tmv.totalWithOptions.usedTradeIn;
            });
        }
    },
    ready: function(){
        this.changeYear();
    }
});
</script>```

Things work fine except that when I post the form, I don't get the vehicle data, because there are no `name` attributes on the fields. If I add the `name` attribute to the "year" field, Vue breaks. By that I mean the value in `data.trade.year` gets erased and the 2 way binding no longer works. Any ideas?
28 Jan
3 years ago

pstephan1187 started a new conversation ExpectsEvents() Not Capturing Events

I am trying to test a job in my application that fires a series of events. If I setup event listeners in my test class, they will fire, however the $this->expectsEvents() method is not capturing them correctly. Here is where I am checking for events:

<?php

namespace Site;

use DB;
use Site;
use Module;
use TestCase;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Torch\Modules\Site\Models\Site as SiteModel;
use Torch\Modules\Site\Commands\CreateSite as CreateSiteCommand;
use Torch\Modules\Site\Commands\DestroySite as DestroySiteCommand;

class CommandTest extends TestCase {

    use DispatchesJobs;

    /** @test */
    public function site_commands_create_and_delete_model_and_site_database()
    {
        Module::load('Theme');
        Module::load('Gate');
        Module::load('Site', 0);
        Module::init();
        
        // This Fires!
        \Event::listen('site.creating', function(){
            echo "Site Creating! \n";
        });

        // this fails with: Exception: These expected events were not fired: [site.creating]
        $this->expectsEvents('site.creating');

        // $this->expectsEvents([
        //  'site.creating',
        //  'site.creating.model',
        //  'site.created.model',
        //  'site.creating.database',
        //  'site.created.database',
        //  'site.created'
        // ]);

        $site = [
            'label' => 'New Test Site',
            'domain' => 'torch.app',
            'template' => 'default',
            'parent_site' => 'webtorch'
        ];

        //This is where the events are fired
        $this->dispatch(new CreateSiteCommand(
            $site['label'],
            $site['domain'],
            $site['template'],
            $site['parent_site']
        ));

        $site_slug = 'new-test-site';
        $Site = SiteModel::find($site_slug);
        $database_name = Site::getSiteDatabaseName($Site->slug);

        $this->assertNotNull($Site);
        $this->assertEquals('test-site-'.$site_slug, $database_name);

        $database_count = DB::connection()->getPdo()->query("SHOW DATABASES LIKE '".$database_name."'")->rowCount();

        $this->assertEquals(1, $database_count);

        $this->dispatch(new DestroySiteCommand($site_slug));
        $this->assertNull(SiteModel::find($site_slug));

        $this->expectsEvents([
            'site.destroying',
            'site.destroying.model',
            'site.destroyed.model',
            'site.destroying.database',
            'site.destroyed.database',
            'site.destroyed'
        ]);

        $database_count = DB::connection()->getPdo()->query("SHOW DATABASES LIKE '".$database_name."'")->rowCount();

        $this->assertEquals(0, $database_count);
    }
}

And here is the site creation job:

<?php

namespace Torch\Modules\Site\Commands;

use DB;
use Site;
use Event;
use Schema;
use Module;
use Validator;
use Torch\Jobs\Job;
use Illuminate\Database\Schema\Blueprint;
use Torch\Modules\Site\Models\Site as SiteModel;

class CreateSite extends Job
{

    protected $attributes = [
        'slug' => null,
        'label' => null,
        'domain' => null,
        'theme' => null,
        'parent_site' => null,
    ];

    public function __construct($label, $domain, $theme, $parent_site, $slug = null)
    {
        $this->attributes['label'] = $label;
        $this->attributes['domain'] = $domain;
        $this->attributes['theme'] = $theme;
        $this->attributes['parent_site'] = $parent_site;

        $this->attributes['slug'] = $slug ?: str_slug($this->attributes['label']);
    }


    public function handle()
    {
        DB::transaction(function(){
            Event::fire('site.creating', [$this->attributes]);
            Event::fire('site.creating.model', [$this->attributes]);

            $validator = Validator::make($this->attributes, SiteModel::getValidation());

            if($validator->fails()){
                Event::fire('site.creating.error', [$this->attributes, $validator->errors()]);
                return;
            }

            $Site = new SiteModel();

            $Site->slug = $this->attributes['slug'];
            $Site->label = $this->attributes['label'];
            $Site->domain = $this->attributes['domain'];
            $Site->theme = $this->attributes['theme'];
            $Site->parent_site = $this->attributes['parent_site'];
            $Site->is_active = true;

            $Site->save();

            Event::fire('site.created.model', [$Site]);
            Event::fire('site.creating.database');

            $connection_name = $database_name = Site::getSiteDatabaseName($Site->slug);

            DB::connection()->getPdo()->exec('CREATE DATABASE `'.$database_name.'`');
            Site::createSiteDatabaseConnection($connection_name, $database_name);

            Schema::connection($connection_name)->create('modules', function(Blueprint $table)
            {
                $table->engine = "InnoDB";
                
                $table->string('slug')->unique();
                $table->string('label');
                $table->timestamps();
                $table->softDeletes();

                $table->primary('slug');
            });

            foreach(Module::getCoreModules() as $module_name){
                $ModuleClass = Module::getModuleClass($module_name);
                $ModuleClass::install($connection_name);
            }

            Event::fire('site.created.database', [$Site]);
            Event::fire('site.created', [$Site]);
        });
    }
}

Any ideas on why the test function expectsEvents() isn't working as expected?

19 Jan
3 years ago

pstephan1187 left a reply on How Can I Make A Controller In Level-2 Folder Of “Controllers”?

php artisan make:controller admin/Controller

The command will also create the folder if it doesn't exist.

pstephan1187 left a reply on Help Me With My HREF Please

The function you are looking for is asset(). https://laravel.com/docs/5.2/helpers

05 Jan
3 years ago

pstephan1187 left a reply on Overridden StartSession Middleware Not Persisting Session

Come to find out, the Session Service Provider registers the middleware, so I have to extend the service provider and register my own middleware for it to work.

pstephan1187 started a new conversation Overridden StartSession Middleware Not Persisting Session

I am trying to implement a custom StartSession Middleware. No matter what I try, it seems that anything other than the Illuminate StartSession Middleware will not persist the session. I have tried using a class that extends the Illuminate one and I have also tried copying the Illuminate one verbatim (updating the namespace of course). But no matter what I try, the session will not persist. I am using the File session driver. When I use the Illuminate middleware, a session file is created when a page is requested, but not on any custom middleware. Any ideas? Essentially I want to add an event to the session middleware.

19 Oct
3 years ago

pstephan1187 started a new conversation Including Bootstrap In "Vueify"ed Component

I am trying to create a Vue component using vueify as laid out here: https://laracasts.com/series/learning-vuejs/episodes/14

I can get everything setup and working properly according to that video. I was even able to get vueify to compile sass for me in the style tag. I, however, cannot seem to get it to import Bootstrap.

This didn't work:

//Alert.vue
<style lang="sass">
@import "bootstrap";
.v-alert {
    @extend .alert
}
</style>
...
//gulpfile.js
elixir.config.js.browserify.transformers[2].options.sass = {
    includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
};

elixir(function(mix) {
    mix.browserify('main.js');
});

I get a file to import not found or unreadable: bootstrap error

I tried creating a vueify.config.js file (as laid out here: https://github.com/vuejs/vueify#pre-processor-configuration) in my app root with this content:

module.exports = function (vueify) {

  vueify.option('sass', {
    includePaths: ['node_modules/bootstrap-sass/assets/stylesheets']
  })

}

And I get an error telling me that option is not a function.

I have also tried just importing the bootstrap file giving the full path. I have tried including and not including an ending slash in my "includePaths" setting. Nothing seems to work. Any ideas?

10 Sep
3 years ago

pstephan1187 left a reply on Persisting Databases Upon Vagrant Destroy

I'm not sure if there is a way to persist the DB but I do know that that is what the database seeder is for. If you have a bunch of development data you want every time you setup your app, then setup your seeders to inject the data and run them whenever you setup the app.

18 Aug
3 years ago

pstephan1187 started a new conversation Getting CLI Or Queue Arguments Within Service Providers

I have a slightly complicated problem. I am building a multi-site CMS on top of Laravel. Each site can have it's own set of "modules" installed. There is a database which lists which modules get loaded on each site.

When the app is booted up, I have a service provider that will detect which site is meant to be opened. Once the site has been determined, that same provider will then run the service providers for each installed module.

This is all works great... until I try to queue commands. The problem is that the site detection algorithm can't determine which site is loaded. It detects based on the domain or the logged in user and since no domain is used and no user is logged in, it fails.

To fix this problem, I need to know which site is being loaded no later than when the app/Providers/AppServiceProvider.php is registered. Is there any way to do that? Can I pass a site variable to the queued command or the artisan command and access it from within the AppServiceProvider.php file? Any ideas would be greatly appreciated.

PS - Once the AppServiceProvider.php file has been registered, I cannot simply override the loaded site. Configs have been loaded, database connections have been established, etc. Breaking all that down and re-initializing would be a nightmare.

Thanks!

31 Jul
3 years ago

pstephan1187 left a reply on Best Approach To Multiple Domains In Same Project

You can group your routes by domain:

Route::group(['domain' => 'www.domain.com'], function(){
    //...
});

Route::group(['domain' => 'mobile.domain.com'], function(){
    //...
});

Route::group(['domain' => 'admin.domain.com'], function(){
    //...
});
29 Jun
4 years ago

pstephan1187 left a reply on AngularJS Controller Not Instantiating

Thanks, @SP1966! It's always those simple things.

pstephan1187 started a new conversation AngularJS Controller Not Instantiating

I am using AngularJS on my app. I've never had any troubles working with Angular in the past and I have worked with it many times. But this is just boggling me. I have the module declared and it is working fine, but my controller fails to work at all. Here is the entirety of the code on my page:


<!DOCTYPE html>
<html lang="en">
<head ng-app="torch">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Torch</title>

    <link href="/compiled/css/app.css" rel="stylesheet">
    <link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>

    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>


    <div class="container-fluid">
        <div class="row">
            <div id="sidebar" class="col-sm-3 col-lg-2">
                <ul class="list-group">
            <li class="list-group-item"><a id="page_manager" title="Pages" href="http://production.matthewandandrew.org/admin/pages"  >Pages</a></li>
    </ul>
            </div>
            <div id="content" class="col-sm-9 col-lg-10">
                <h1>Pages</h1>
                <div ng-controller="what">
    {{test}}
</div>
            </div>
        </div>
    </div>


    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <script>
        var App = angular.module('torch', []);
    </script>
        <script>
        console.log(App);
        
        App.controller('what', ['$scope', function($scope){
            $scope.test = 'WHAT THE HECK?!';
            console.log('hello2');
        }]);
    </script>
</body>
</html>
  • The App var gets logged to the console fine
  • {{test}} never gets interpolated and shows up as {{test}} on the web page
  • 'hello2' never gets output to the console

I am sure this is probably something super stupid like a missing comma or semicolon, but I have been working on this for hours and am officially whooped. Also, no errors are output to the console.

pstephan1187 left a reply on VueJs Component Element Node

This wasn't necessarily the solution I was looking for, but this works:

    ready: function(){
        this.svg = d3.select(this.$el)[0][0];
        this.hex_container = d3.select(this.svg).select("g");// Error occurs here
    }
17 Jun
4 years ago

pstephan1187 left a reply on VueJs Component Element Node

Note that I had to add spaces between the curly braces to get them to display on the forum.

pstephan1187 started a new conversation VueJs Component Element Node

I am working on an app the utilizes D3 and Vue. I was originally building it with AngularJs, but decided to switch so that I could learn Vue. One problem I am running into is that I cannot seem to figure out how to get D3 to select a Vue Component's element.

In Angular, I had a custom directive set up for an HTML tag I was creating. This directive's link property was pointing to a function like this: function(scope, element, attrs){}. Within that function D3 could properly select HTML nodes like this: d3.select(element[0]).

However, when trying to do something similar in Vue, I can't get it to work. I am creating a Vue component via Vue's extend method: var component = Vue.extend({...}) and then registering it: Vue.component('myhtmltag', component);. The issue is that these don't seem to work in my ready event:

this.svg = d3.select(this.$el);
this.svg = d3.select(this.$el[0]);
this.svg = d3.select(this.$el.childNodes[0]);

When Attempting to run more d3 functions on this.svg, I get this error (when it worked just fine using Angular):

Uncaught TypeError: undefined is not a function

Here is the applicable code:

var Vue = require('../node_modules/vue');
var d3 = require('../node_modules/d3');

var Galaxy_Element = Vue.extend({
    template: '<svg viewBox="0 0 {{width/zoom}} {{height/zoom}}" preserveAspectRatio="xMinYMin slice">'+
                    '<g id="hexes" transform="translate(0, 0)"></g>'+
                  '</svg>',
    props: ['map'],
    methods: {

    },
    data: function(){
        return {
            'name': '',
            'width': 0,
            'height': 0,
            'zoom': 1,
            //a few more properties

            'svg': null,
            'hex_container': null,
        }
    },
    compiled: function(){
        var json = require('../maps/'+this.map+'.json');

        this.name               = json.name;
        // more assigning of properties
    },
    ready: function(){
        this.svg = d3.select(this.$el);
        this.hex_container = this.svg.select("g");// Error occurs here
    }
});

Vue.component('galaxy', Galaxy_Element);

module.exports = Galaxy_Element;
27 May
4 years ago

pstephan1187 left a reply on Proper Way To Edit Code Between Two Git Branches

Well, I ended up going with stashing the changes, switching branches and committing the changes to the branches as necessary, merging to master, then rebasing my current branch with the updated master. Looks good. Hopefully I didn't screw anything up :/

pstephan1187 started a new conversation Proper Way To Edit Code Between Two Git Branches

I am developing an application and I am constantly coming across cases where I am editing a "module" under one branch when I need to make an edit in another "module" that is being developed under a different branch. What is the best way to handle this?

  • Make the edit in the branch you are currently working on
  • Stash the edit, finish developing current module, switch branches, unstash (rebase?)
  • Commit your current changes, switch branches, make change switch back (rebase?)
  • Other

Does it make a difference if the change is necessary under my current branch as opposed to not being necessary (visual change vs operational change)?

I am still learning the ropes on Git and could use any advice.

Note, I am the only one currently developing on the whole repo (that won't necessarily always be the case) but I am pushing changes to Bitbucket.

pstephan1187 left a reply on Changing Domain In Integrated Testing

It appears that the error was in my service provider that detected the domain. It was a singleton, and somewhere in the testing, the initial request is made over localhost, then switched to my domain. Changing my SP to bind fixed the issue. Not my favorite, but it will do.

pstephan1187 left a reply on Changing Domain In Integrated Testing

I also tried overriding the Laracasts\Integrated\Extensions\Laravel baseUrl() method:

public function baseUrl(){
    return 'http://my-domain.com';
}

That didn't work either.

pstephan1187 started a new conversation Changing Domain In Integrated Testing

I am creating a multisite CMS and I need to be able to test my services via different domains with the Laracasts Integrated test package. Is there a way to tell Integrated to test my Laravel application on a domain besides localhost? This does not work:

class TorchTest extends TestCase {
    protected $baseUrl = 'http://my-domain.com';
    //... more code ...
}

Also, is there a way to change the domain on the fly within tests like so?

public function test_sites_package_correctly_determines_domain_and_site(){
    $this->baseUrl = 'http://my-domain.com';
    $Site = $this->app->make('Site');
    $domain = $Site->getDomain();
    $this->assertEquals('my-domain.com', $domain);
    
    $this->baseUrl = 'http://another-domain.com';
    $Site = $this->app->make('Site');
    $domain = $Site->getDomain();
    $this->assertEquals('another-domain.com', $domain);
}
26 May
4 years ago

pstephan1187 left a reply on Running PHP Files From S3

This is actually the answer I am looking for: https://aws.amazon.com/efs/

11 May
4 years ago

pstephan1187 left a reply on Artisan Scheduler Cron Command

Ok, so anything sent to $this->info() or $this->error() is discarded then? As for errors, those are still caught and sent to the log?

pstephan1187 started a new conversation Artisan Scheduler Cron Command

The Laravel documentation says to add this command for scheduled events in Laravel:

* * * * * php /path/to/artisan schedule:run 1>> /dev/null 2>&1

I get the first part, but what does this do?

1>> /dev/null 2>&1

What do the numbers, brackets, and ampersand do and what is /dev/null?

Thanks!

20 Apr
4 years ago

pstephan1187 left a reply on Editors

Libraries like TinyMCE and CKEditor are great. They will automatically filter the content before it is sent to the server (removing things like <script> tags) and make sure that no abusive code is used. They are also highly configurable so you can adjust the settings to your liking (like allowing the use of iframes or not allowing the use of images).

But as with any form of user input, NEVER trust it. Always validate and filter on the server side before saving content to a database or injecting it into HTML.

Essentially, Javascript WYSIWYG editors are just fancy <textarea> elements. Anyone can put HTML tags in a text area. How secure the app is is completely determined by how you process the data.

14 Apr
4 years ago

pstephan1187 left a reply on Why With Not Working In Laravel 5

Not sure I am following what you are looking for. Is this what you want?

public function parent()
{
    return $this->belongsTo('App\Navigation', 'parent_id')->where('parent_id', 0)->where('id', '!=', 0);
}

pstephan1187 left a reply on Why With Not Working In Laravel 5

@Sonu, if the answers are the same, you would typically pick the first one. In this case, however, @blackbird gave a more complete answer so his is the one to choose. As for your last question:

public function parent()
{
    return $this->belongsTo('App\Navigation', 'parent_id')->where('parent_id', 0);
}

pstephan1187 left a reply on Why With Not Working In Laravel 5

In Laravel 5 you have to include the namespace in the model declaration:

return $this->belongsTo('\App\Navigation', 'parent_id');
06 Apr
4 years ago

pstephan1187 left a reply on Jeffrey, And To An Extent The Serious Laracasts Subscribers, Are Subject To Vitriol. My 2c

Absolutely agreed. I wish I could "Thumbs up" your post. Those who dedicate their time to GIVE to others are often the target of absurd abuse, and the abusers can hide so easily behind a computer screen, a fake email address and a screen name. We need to make sure we show our gratitude to those who do so much for the community.

01 Apr
4 years ago

pstephan1187 left a reply on Sending 2 Variables With Blade?

return View::make('intro')->with( ['data' => $data, 'position' => $pos ] );
31 Mar
4 years ago

pstephan1187 left a reply on Keyby A HasMany Relationship

@JarekTkaczyk Yeah, that's what I kept coming to. Oh well, I guess I actually have to write some code instead of relying on Eloquent to do everything for me :)

pstephan1187 started a new conversation Keyby A HasMany Relationship

I have three models. Let's call them "A", "B", and "C". Model "A" has a HasMany relationship with model "B" and model "B" has a HasMany relationship with model "C". I am making a call to eager load models "B" and "C" when I load model "A":

ModelA:with('ModelB.ModelC')->find('model_a_id');

That works fine, however, it would be very beneficial to be able to keyBy() ModelC's results. Here is what I am getting:

ModelA
    Property_1
    Property_2
    ModelB
        [0]
            Property_1
            Property_2
            ModelC
                [0]
                    Property_1
                    Property_2
                [1]
                    Property_1
                    Property_2
        [1]
            Property_1
            Property_2
            ModelC
                [0]
                    Property_1
                    Property_2
                [1]
                    Property_1
                    Property_2

However, this is what I would like to get:

ModelA
    Property_1
    Property_2
    ModelB
        [0]
            Property_1
            Property_2
            ModelC
                [Property_1_value]
                    Property_1
                    Property_2
                [Property_1_value]
                    Property_1
                    Property_2
        [1]
            Property_1
            Property_2
            ModelC
                [Property_1_value]
                    Property_1
                    Property_2
                [Property_1_value]
                    Property_1
                    Property_2

Typically, on a collection, you can run ModelC->keyBy('property_1') and get a new collection. But I want to run the keyBy() method from within the eager loading.

Essentially, I want to do this:

ModelA:with('ModelB.ModelC' => function($query){
    return $query->keyBy('property_1');
})->find('model_a_id');

Any ideas on how I can accomplish this?

12 Mar
4 years ago

pstephan1187 left a reply on Proper Use Of Git

Great! Thanks for the tips. Relieving to know I wasn't doing it dead wrong :)

pstephan1187 started a new conversation Proper Use Of Git

I am just learning how to use git with multiple team members. Been learning how to use it by myself, which is not too hard. Big question is: when I make changes to a branch and another person makes changes to that same branch (which have been pushed to origin), what is the best way to merge those changes (from origin)?

I have been doing this:

git pull origin master
git commit -m "my new commit"
git push origin master

Is that the correct way of doing it, or am I going about it all wrong?

11 Mar
4 years ago

pstephan1187 left a reply on How To Hash User Input Password When Using Form Validation In Form Request( Laravel 5)

A good way to handle that would to create a setter method on your eloquent model:

public function setPasswordAttribute($value){
    $this->attributes['password'] = bcrypt($value);
}

Anytime a password is assigned, it will be hashed.

pstephan1187 left a reply on Can't Connect To MySQL Using Clients, Only Via Console. L5

Make sure you are using the right port number: 33060

pstephan1187 left a reply on Should I Be Using Middleware For This?

Why don't you just add it as a method on your User eloquent model?

public function getBranchUsers(){
    if ($this->hasPermission(['admin'])){
        return self::orderBy('name', 'asc')->get();
    }else{
        return self::where('branch_id', '=', $this->branch_id)->orderBy('name', 'asc')->get();
    }
}

Then in your controller (or wherever you use it) you can do this:

$users = Auth::user()->getBranchUsers();
07 Mar
4 years ago

pstephan1187 left a reply on Action Not Defined

I had to do with the namespacing in the RouteServiceProvider. I included my controllers in the map method and it worked fine. Alternatively, I could have removed the root namespace from the RouteServiceProvider and explicitely specified App\Http\Controllers where needed:

    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function($router)
        {
            require app_path('Http/routes.php');
        });

        $router->controller('/', 'Phpusion\LaravelAuthStub\Controllers\LoginController');
        $router->controller('/', 'Phpusion\LaravelAuthStub\Controllers\RegisterController');
        $router->controller('/', 'Phpusion\LaravelAuthStub\Controllers\PasswordController');
    }

pstephan1187 left a reply on Action Not Defined

@usman Unfortunately, that did not work. I also tried composer updateing, but that didn't help either :(

pstephan1187 started a new conversation Action Not Defined

I am setting up my own package that has its own controllers, views, config file, etc. Everything was going fine and dandy until I tried using the URL action method to create a link to one of the controller methods. I am getting an "action not defined" error. However the action is clear as day when I run php artisan routes:list.

So my package is PSR-4 namespaced under Phpusion\LaravelAuthStub. I have a \Phpusion\LaravelAuthStub\Controllers\LoginController class located under packages/phpusion/laravel-auth-stub/src/Controllers/LoginController.php. I can reference it fine this way (along with two other controllers):

Route::controller('/', '\Phpusion\LaravelAuthStub\Controllers\LoginController');
Route::controller('/', '\Phpusion\LaravelAuthStub\Controllers\PasswordController');
Route::controller('/', '\Phpusion\LaravelAuthStub\Controllers\RegisterController');

However, when I try to create a link using the action helper, I get problems. This returns a Action Phpusion\LaravelAuthStub\Controllers\LoginController@getLogin not defined error:

dd(App::make('url')->action('\Phpusion\LaravelAuthStub\Controllers\LoginController@getLogin'));

This works fine:

dd((new \Phpusion\LaravelAuthStub\Controllers\LoginController())->getLogin());

Any idea what I am doing wrong? Is this a bug, perhaps?

27 Feb
4 years ago

pstephan1187 left a reply on Use GetID3 In Laravel 5

Assuming this is the one you want: https://github.com/JamesHeinrich/getID3/ you would run this command in your root directory:

composer require james-heinrich/getid3

Then you should be able to call $getID3 = new \getID3; anywhere in your code.

18 Feb
4 years ago

pstephan1187 left a reply on Trying To Create Composer Package. Class Not Found.

@JarekTkaczyk, This works for PSR-0 and allows me to develop more than one package under the same namespace:

"PHPassion\\Edmunds\\": "packages/PHPassion/Edmunds/src/"

pstephan1187 left a reply on Trying To Create Composer Package. Class Not Found.

It's always the stupid simple things that drive you mad in programming. The Namespace is PHPassion, not PHPashion >_<