CrtlAltDylan

CrtlAltDylan

Member Since 4 Years Ago

Philadelphia, PA

Backend OOP specialist at Freelance

Experience Points 7,760
Experience Level 2

2,240 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 96
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

16 Mar
3 years ago

CrtlAltDylan left a reply on Auth::user() Return Null On Laravel 5.2

Nice find @Sithira

However my life just got harder because you have to implement a CSRF token during the POST. Woof.

23 Feb
3 years ago

CrtlAltDylan left a reply on [Package] Larasupport - Adds Laravel Package Support In Lumen

Awesome. Just what I was looking for. Does it include the app() helper? I too am sharing code between a Lumen and Laravel app, kind of hard to test without the support.

29 Jan
3 years ago

CrtlAltDylan left a reply on Using Jobs In Lumen

I also noticed that jobs aren't syncronous. You need to run php artisan queue:work to see results.

CrtlAltDylan left a reply on Lumen Cusom Config Not Being Picked Up

I need to bump this, tried all the above advice and still unable to get a custom config which is a huge problem.

14 Jan
3 years ago

CrtlAltDylan left a reply on Installing Xdebug In Homestead Running Php7

Excellent! Thank you. Will mark as answered once I get a chance to try it. Right now wrestling Amazon Datapipelines haha

13 Jan
3 years ago

CrtlAltDylan started a new conversation Installing Xdebug In Homestead Running Php7

I'm having a hard time figuring out how to enable/install xdebug in the newest Homestead version. Has anyone else figured out how to install it?

Tried:

  1. apt-get installing with php5 and php7
  2. installing from source but unable to find the php7 binary to phpize the xdebug binary

Just trying to get codeception's code coverage back. Thanks!

17 Dec
3 years ago

CrtlAltDylan started a new conversation Laravel5 Module + Codeception Not Loading .env.testing

There's a few other threads about this scattered across the web. Has anyone gotten a permanent fix for 5.1?

16 Dec
3 years ago

CrtlAltDylan left a reply on How To Set Up And Define Your Database For Integration Testing

Thank you! I can't believe how hard it is to figure out testing in Laravel.

For unit/integration tests I'm very happy with Codeception.

However there are a number of things that screw up using codeception:

  1. Without the Laravel5 module, you cannot use namespaced classes/facades in your application code
  2. If you use the Laravel5 module you cannot use it with the acceptance testing suite, even if you use that little snippet in the Laravel5 module docs.
  3. As far as I can tell with the Laravel5 module, you cannot authenticate as a user.
  4. In theory you should be able to use the PHP league faker library, but in fact you can't because it's facade based and codeception doesn't play well with that. Even the documentation on using the faker library admits this.
  5. Using Laravel's built in testing suite is relies on the phpunit.xml file for configs not an easy yml loading a .env.testing
  6. Laravel's testing documentation is not nearly as good as codeceptions. I wish I could just use codeception and be able to test all aspects.
14 Oct
3 years ago

CrtlAltDylan left a reply on Occasionally Web Server Unable To Write On Storage/logs On Production Environment

Found out it was supervisor being the cause of the problem.

Supervisor was running as root, which would write it's logs with root as the owner.

To fix I had to add the user in the supervisor program:

[program:your_supervisor_program_name]
user=ec2-user

CrtlAltDylan started a new conversation Occasionally Web Server Unable To Write On Storage/logs On Production Environment

Using AWS as my host, occasionally the production server is unable to write logs to the storage/logs/* and causes my application to white-screen. I don't sudo when git pull'ing and my storage owner/group/permissions are as follows:

drwxrwxr-x 6 apache apache

There doesn't seem to be any sort of pattern as to when the white-screen'ing happens. It's without any sort of admin pulling or messing with files, it happens "naturally". Is there a small daemon or something that could be changing permissions?

CrtlAltDylan started a new conversation Flux With Elixir

I'm looking to dive into a Flux like implementation to help with React complexity. I'm curious if anyone else in the Laravel world is doing something similar, especially since I rely on Elixir to compile all of my React.

A few questions:

  1. Can I use native gulp in the same gulpfile that Exilir uses without conflict?
  2. Is there any Flux like implementations that work "out of the box" with Exilir's browserify workflow?

After doing Laravel for awhile it's really fun to move into the frontend, but geeze there are so many options and opinions! Too bad there's not a resource like laracasts for react like implementations.

02 Sep
3 years ago

CrtlAltDylan left a reply on Unable To Mock The Config::get('configuration.here'); Facade Method

@Alex C. using the helper or facade causes the same issue. Good thought though.

@jesseschutt Sorry, I have yet to find a fix. My app uses quite a bit of the config facade which is kind of a bummer.

26 Aug
3 years ago

CrtlAltDylan started a new conversation React + Exilir + Browserify Not Loading Local React Modules

Trying to use the ES5 style of importing modules:

var React = require('react');
var $ = require('jquery');

But the problem comes when trying to use local scripts I've made:

    mix.browserify([
    '../../../node_modules/react-bootstrap/dist/react-bootstrap.min.js',
        '/AlphaCharacter.js',
        '/Alphabet.js'

    ], 'public/js/Alphabet.js');

The Alphabet react module in this case has a AlphaCharacter dependency, and when it's trying to render:

Uncaught TypeError: AlphaCharacter is not a named module

How can I expose AlphaCharacter to the Alphabet? Thanks!

CrtlAltDylan left a reply on Gulp Watch With Elixir Not Watching

Ah that makes sense. The exilir docs need an update with this nifty

11 Jun
3 years ago

CrtlAltDylan started a new conversation Unable To Mock The Config::get('configuration.here'); Facade Method

All of the other Facade mocks work great, but this Config one in particular is acting as if it's not in test mode. I'll show you what I mean: class Stub { public function someAction() { return $someConfig = config('appName.some.configuration'); // works great, I can set and get all kinds of configurations from /config/app/appName.php } } However when I try to test my fancy Stub class: class StubTest extends \Codeception\TestCase\Test { protected function _before() { $this->stub = new Stub(); }

   public function testStubSomeActionUsesMyApplicationsConfig()
   {
         \Config::shouldReceive('offsetGet')->with('appName.some.configuration')->andReturn('Yay, mocked!');

         $this->assertEquals('Yay, mocked!, $this->stub->someAction());
   }

} You would expect this to be a passing test. However when the Config is being mocked, it begins to ask for other configuration variables that this test shouldn't care about: [Mockery\Exception\NoMatchingExpectationException]
No matching handler found for Mockery_2_Illuminate_Config_Repository::offsetGet("database.default"). Either the method was unexpected or its arguments matched no expected argument list for this method If you start to mock the configuration for database.default, it'll move onto your cache configuration. On top of that it asks for real values. It's a waste of time and not sustainable. Has anyone else run into this issue when mocking the Config facade?

18 Mar
4 years ago

CrtlAltDylan left a reply on Laravel 5 Form Builder

Very cool!

12 Jan
4 years ago

CrtlAltDylan started a new conversation Accessing Specific Subtypes Of A Polymorphic Relationship

This is a general best practice kind of question. My application is a little more complex and I have found using polymorphic relationships really help you scale and normalize your database.

However sometimes it leads me to have to do things like this on some models:

User class extends Eloquent
{
    /**
     * A user has many transportations (Rides, Flights, Bus rides, etc)
    public function transportations()
    {
        return $this->morphMany('Transportation', 'transportationable');
    }

    /**
     * I need to be able to grab all of the flights a user has
     */
    public function flights()
    {
        // Getting all transportations of the Flight type
        $flightTransportations = $this->transportations(function($transportation)
        {
            return $transportation->transportationable_type = 'Flight';
        })
        //Converting the collection to actual Flight objects not Transportation objects
        $flights = $flightTransportations->map(function($flightTransportation)
        {
            return Flight::find($flightTransportation->transportationable_id);
        });

        return $flights;
    }
}

As you can see this gets a little old after awhile. Is there a hasThrough method for polymorphic relationships that I'm not aware of?

17 Dec
4 years ago

CrtlAltDylan left a reply on Form::select() With A Default Value That Doesn't Exist In The List

Yup your solution works just as well. Thank you!

CrtlAltDylan left a reply on Form::select() With A Default Value That Doesn't Exist In The List

Found it:

<div class="row">
    {{ Form::select('sectionPrototypes', array('default' => 'New Section') + $currentUser->sectionPrototypes->lists('name','id') ) }}
</div>

CrtlAltDylan started a new conversation Form::select() With A Default Value That Doesn't Exist In The List

I have a model that has a "new" option in case the user doesn't want any of the other sectionPrototypes they have made.

I would like to use "New Section" as the default value, but since there is no sectionPrototype in the list, Laravel doesn't show any option whatsoever.

Code:

<div class="row">
     {{ Form::select('sectionPrototypes', $currentUser->sectionPrototypes->lists('name', 'id'), 'New Section') }}
</div>

Screenshot of empty select box: http://puu.sh/dyXjD/df9c4a82a3.png

I'd much rather use the Blade Form, because it's so much cleaner of an implementation. However if I can't use the default value, I'm kind of screwed because a user has no sectionPrototypes when they first create an account.

CrtlAltDylan left a reply on Automating Deployment In Iterations?

Did some more research and found Envoy, it's Laravel's custom answer for Fabric: https://github.com/laravel/envoy

CrtlAltDylan started a new conversation Automating Deployment In Iterations?

Just reading through this article about web development in general:

@ks_aps/writing-a-web-application-do-it-right-fd14973f162" target="_blank">https://medium.com/@ks_aps/writing-a-web-application-do-it-right-fd14973f162

It recommends a few tools for automating deployment like ansible and fabric. Do any of you use tools like these? I kind of understand the value. You can deploy new code with schema changes and whatnot without having to break your team's instances.

15 Dec
4 years ago

CrtlAltDylan left a reply on Adding Data To A Pivot Table

With Eloquent you don't have to think about pivot tables.

$modelInstance->$relatedModel->save($theRelatedModelInstance);

Does it all for you

CrtlAltDylan left a reply on How Can I Use Laravel 4 Packages For Laravel 5?

I would recommend using 4 until 5 is more accepted.

13 Dec
4 years ago

CrtlAltDylan left a reply on Weird Float To String Problem, Trying To Charge Stripe A 1/100000th Of A Penny

Thanks for the pointer. Learning this lesson the hard way.

CrtlAltDylan left a reply on Weird Float To String Problem, Trying To Charge Stripe A 1/100000th Of A Penny

    /**
     * Rounding the float on the way out of the db (Cause Dylan's db has downs)
     */
    public function getPriceAttribute($price)
    {
        return round($price, 2);
    }

http://i1115.photobucket.com/albums/k552/vincent-chong/Blog%20vc8blogspotcom/SmileDerpBlackSS.png

CrtlAltDylan left a reply on Weird Float To String Problem, Trying To Charge Stripe A 1/100000th Of A Penny

Confirmed: It's eloquent or my db. If it's a local problem it must be my db

http://puu.sh/dthzO/a4c830611a.png

CrtlAltDylan left a reply on Weird Float To String Problem, Trying To Charge Stripe A 1/100000th Of A Penny

@bashy it's even weirder that no one else on my team has this problem. Works on dev server just fine too.

CrtlAltDylan started a new conversation Weird Float To String Problem, Trying To Charge Stripe A 1/100000th Of A Penny

The screenshot says it all. The stored value is indeed a float:

http://puu.sh/dtgD7/ef672e2040.png

And this is what I'm trying to charge stripe apparently

http://puu.sh/dtgvQ/763fb1b5af.png

10 Dec
4 years ago

CrtlAltDylan left a reply on Namespaces And Use A Lot Of Things...

The end of Dayle's namespace post is interesting:

<?php

namespace Baratheon;

use Dayle\Blog as Cms;

// app/routes.php

$post = new Cms\Content\Post;
$page = new Cms\Content\Page;
$tag = new Cms\Tag;

I wonder if you could use something like use \ as Laravel;

CrtlAltDylan left a reply on Conflicting Routes Between Blog And Pages

Also I would suggest making the page model a self referencing table if you haven't already.

CrtlAltDylan left a reply on Best Way To Get Collection With Calculated Column Related To Auth::user()

@pmall 's suggestion is usually what I go with if I have to filter or calculate a method that happens over and over throughout my apps.

isFollowing(User $user) , hasFollower(User $user) are perfectly fine.

CrtlAltDylan left a reply on Updating Different Parts Of View Using Ajax Calls ( Big Response Time )

@zefman Thanks for the tip. I will definitely use this in my app.

09 Dec
4 years ago

CrtlAltDylan left a reply on Updating Different Parts Of View Using Ajax Calls ( Big Response Time )

I can't believe I've been using AJAX for all this time and not set up caching on the backend. This would make time sensitive calls extremely fast, like chat for example.

I too am trying to transition one of our UX heavy pages into an Angular app. It just makes sense to have 1 API that iOS/Android/Frontend uses. Also Angular is amazing when it comes to frontend manipulation.

I'm still curious on how you are leveraging the Cache facade though. Do you have some kind of Chain of Responsibility method that figures out if the result is in cache already, if not then query the db?

CrtlAltDylan left a reply on Why Switch From 4 To 5 ?

Yup Laravel 5 is definitely still unstable. But I'm excited for the new Symfony-ish Form Requests.

One of the differences I'm aware of is the removal of the modals directory. To prepare, I suggest learning about PSR-4 autoloading and moving your model logic into a separate src or in Laravel 5 terms, a app folder.

CrtlAltDylan left a reply on Updating Different Parts Of View Using Ajax Calls ( Big Response Time )

@zefman I'm having a similar issue with my app as well. Could you clarify what you mean by caching responses?

CrtlAltDylan left a reply on Free Laravel Application Development EBook

You sir are a gentleman and a scholar. Thank you!

CrtlAltDylan started a new conversation Best Practices For Applying Complex-ish Subscription Rules

I'm excited because my application is getting to a point where I can charge customers ( awesome) and this means I get to implement a payment service.

I've already installed Stripe and Cashier as my payment and payment processing services. However I have some subscription rules that are somewhat complex. Here's just a small sample of the rules:

A basic plan has 1 Artist and 10 Shows. After 10 Shows a $Y amount is charged per Show.

A premium plan has up to 5 Artists and 50 Shows. After 50 Shows a $Y amount it charged per Show.

I will soon have to apply different rules to different user account types. What are some methods that you all use to verify that a User can perform certain actions? I'm thinking that this calls for a separate service altogether that's called on certain routes and before actions are performed:

 SubscriptionChecker::check($action, $user);

Will be responsible for simply checking if the user's account is able to perform the action.

17 Nov
4 years ago

CrtlAltDylan left a reply on Is Table Single Or Multi Table Inheritance Possible With Eloquent?

I did some more searching around, this trick is to leverage polymorphic relationships to "compose" your super class. I love it, very easy to make models superclasses later without a bunch of migrations

http://richardbagshaw.co.uk/blog/laravel-user-types-and-polymorphic-relationships/

CrtlAltDylan left a reply on Is Table Single Or Multi Table Inheritance Possible With Eloquent?

After some searching some people have found ways to create single class inheritance:

https://github.com/Nanigans/single-table-inheritance

http://laravel.io/forum/02-17-2014-eloquent-single-table-inheritance

However I'm not able to find any multiple table inheritance pattern to follow yet. Guess I'm working on the edge of the framework.

CrtlAltDylan started a new conversation Is Table Single Or Multi Table Inheritance Possible With Eloquent?

I have an application that's getting pretty large. I've noticed that one of our tables "locations" is doing the job of several tables. There are many sub-locations that inherit the same properties, but are different enough that they justify their own table (because of additional fields). I've also noticed I need to apply this pattern to another part of my application so it's definitely a pattern worth learning how to do and implementing. Problem is I don't see any documentation on this type of Eloquent feature. Is single and multiple class inheritance out of scope of the Eloquent ORM? I'm working on implementing the repository pattern, so I could possibly switch out to doctrine which I know supports this. I'd just rather stick with Eloquent because it's so easy to use. Has anyone else encountered this problem?

30 Oct
4 years ago

CrtlAltDylan left a reply on Is There A JS Library/plugin Specifically For Dynamic Forms?

@nolros

Exactly what I was asking. I'm not a frontend minded person, but I can see that normal Blade + jQuery is functional but it's just not as scalable as I thought. I'm definitely going to build a RESTful API that both the web and mobile sides of the application.

So many advantages:

1) complete separation of view from the application

2) Don't have to duplicate code for mobile or web, the API expects JSON endpoints as GETers and POSTers.

3) Use a tool that has a separate goal than that of Laravel, but you can still leverage it for your application.

29 Oct
4 years ago

CrtlAltDylan left a reply on Is There A JS Library/plugin Specifically For Dynamic Forms?

@bashy Ohhh and you can use parameters with Form macros. This may be the answer I'm looking for. I'll give it a shot, thank you!

http://laravel-recipes.com/recipes/173/creating-form-macros

CrtlAltDylan left a reply on Is There A JS Library/plugin Specifically For Dynamic Forms?

@bashy that's definitely helpful. There are 3 main use cases that I run into over and over:

1) A form as a type of field that can be added 0, 1, or many times (your typical 'add expense' or 'add contact' field) 2) A field that shows/hides based on certain conditions (like a checkbox causing another part of the form to show) 3) A search bar in the form that makes an AJAX call to a local API endpoint that provides results to the form for a user to selection. That selection is used on the form.

To add to the complexity, many of these forms are on modals. Modals are also a great UX tool, but if you iterate over a collection in your view then you have to generate a corresponding modal with each instance.

Something like this `Edit this object

I think I could leverage some macros to do this but I'm starting to understand why people are using Laravel as a RESTful API for frontend JS when your pages are very user event driven.

CrtlAltDylan started a new conversation Is There A JS Library/plugin Specifically For Dynamic Forms?

Blade is great. It makes reading and writing static forms a cinch. However when it comes to dynamic forms there's not a clear answer. I've been using jQuery functions to add/delete/modify fields based on user events. However this is resulting in a lot of copy pasta which is not yummy and I feel like this is a common enough problem there is a JS library out there specifically for forms.

Is this out of scope for Blade? Is this what frontend JS frameworks attempt to answer?

17 Oct
4 years ago

CrtlAltDylan left a reply on How To Modify The Auth Table Column Names?

If by mapping you mean adding additional columns to your users table you simply create a migration then add fields to the table:

Schema::table('users', function($table) $table->string('new_field_name_here'); );