OneSeventeen

OneSeventeen

Member Since 3 Years Ago

Experience Points 8,950
Experience Level 2

1,050 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 86
Lessons
Completed
Best Reply Awards 0
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.

05 Sep
1 week ago

OneSeventeen left a reply on Dev Workflow

I felt the same way for a few years and didn't see the value in complicating things with version control and everyone having a local copy until I read through "Understanding the GitHub flow": https://guides.github.com/introduction/flow/

Basically everyone can work from the same starting point, but can be working on different areas of the code, regularly submitting their changes as a separate branch or feature to the main code-base. After everyone agrees the code looks safe to include in the project, they can merge the feature into the core code and all the devs can pull down the update core without messing with the changes they themselves are working on.

It sounds a lot more complicated than it is, and it seems to be very successful for projects with just a few developers as well as projects with thousands of developers.

Actually, it sounds a lot like what you are looking for: a central online repository for the single source of the code. It simply adds the ability for devs to each grab a copy to work on locally (where it will be faster and they can each use their own preferred editors/tools/etc) and they can push their changes in a non-destructive way to the single online system.

Personally, after going through the tutorial I've started using the same method of development even on projects I work on alone.

The great thing is, you can use scripts to deploy what you are working on in to a staging environment and into production very easily.

05 Mar
1 year ago

OneSeventeen left a reply on Setting Up A Subscription Service With Free Sub-users

Phenomenal, thanks! Exactly what I was looking for!

I'll read through more of the spark docs to see if that is the best fit for my project, as it looks like it may be.

03 Mar
1 year ago

OneSeventeen started a new conversation Setting Up A Subscription Service With Free Sub-users

I'm looking to make an app using Laravel (and possibly spark) that an administrator would pay a monthly fee for, but that they could then add as many users as they'd like that could access the data they track in my app. Similar to how a basecamp admin pays for the service and invites tons of people to their account that don't have to pay.

Are there any common ways of doing this already? I'd hate to re-invent something.

11 Jul
2 years ago

OneSeventeen left a reply on Calculate If Model Is Active Based On Start And End Dates

When I called a custom function on my model it threw the following:

Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

here's what I wound up doing in my model that works:

    protected $appends = ['active'];

    public function getActiveAttribute() {
      if( ( $this->begin_at == null || strtotime($this->begin_at) < time() )
      && $this->end_at == null || strtotime($this->end_at) > time() ) {
        return true;
      } else {
        return false;
      }
    }

This was based on @ntzm in the slack channel pointing me towards Eloquent Accessors & Mutators

Adding the 'active' value to the $appends array makes the attribute visible in JSON responses.

Just to confuse me to no end, I can now add custom methods and it works as I originally had expected it to... perhaps "active", "expired", or "began" was a reserved method?

Oh well, this seems to be the "proper" method anyway. And the reason I care about best practices is I hope to upgrade to future versions of Laravel at some point, and I intend on supporting this code for a few years at the least.

OneSeventeen started a new conversation Calculate If Model Is Active Based On Start And End Dates

I have begin_at and end_at columns in a "surveys" table and am constantly adding code like this:

if( ($survey->begin_at == null || strtotime($survey->begin_at) < time())
    && ($survey->end_at == null || strtotime($survey->end_at) > time())) {
    //do stuff since the survey is active
}

I'd love to just add that in a method on my survey model so I can change that to:

if( $survey->active() ) {
 //do stuff since the survey is active
}

Especially considering I could check that in views as well.

Any thoughts on the best practice for accomplishing this? Or should I just keep repeating the more drawn out logic?

OneSeventeen left a reply on How Do I Distribute Work Across Multiple Servers?

Thanks, this was really helpful to point me in the right direction. I wasn't sure if there was some magic sauce that Laravel had built in for this type of thing.

That's a lot of great material and I think it will help me immensely.

13 Jul
3 years ago

OneSeventeen started a new conversation How Do I Distribute Work Across Multiple Servers?

I would like to develop a large application but want to be able to distribute the workload across multiple servers. What is the best way to do this?

I am hoping for a general direction, as I realize this is a VERY broad question. I'm not sure if I should just look into server-clustering, separation of concerns, or some other crazy method.

I'm really hoping for near-real-time data changes, so anything that relies on synchronizing data every few minutes wouldn't work.

I mainly don't want to start writing an app that needs scalability and find out a year from now I should have been doing something else specific to prime my app for multi-server deployment.

Thanks!

19 Mar
3 years ago

OneSeventeen started a new conversation Redirect With Flash Data Not Showing In Blade

In my controller:

return redirect('/switch/device/' . $id)->with('status', 'Successfully updated device');

In my blade view:

@if ( session('status') )
  <div class='alert alert-{{ session('notice-type') or "info"}} alert-dismissible' role='alert'>
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    {{ session('status') }}
  </div>
@endif

This status div will never show up. I've switched to simply passing data to a view rather than redirecting, but I'd love to use flash data in my master template for purposes like this.

26 Feb
3 years ago

OneSeventeen left a reply on Defining Tables That Will Bridge Other Tables

I figured I'd give an update since I have a working system now, in case someone searches for a similar question:

Devices - things that are plugged into a network switch that have a MAC address

Schema::create('devices', function (Blueprint $table) {
    $table->increments('id');
    $table->string('mac_address', 12)->unique();
    $table->string('description')->nullable();
    $table->timestamps();
});

Network Switches

Schema::create('network_switches', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name')->nullable();
    $table->string('description')->nullable();
    $table->string('ip', 15);
    $table->string('snmp_community')->default('public');
    $table->string('snmp_version')->default('v2');
    $table->timestamps();
});

Port Associations (the part I was mostly confused about which turned simple)

Schema::create('port_associations', function (Blueprint $table) {
    $table->increments('id');
    $table->integer('network_switch_id')->unsigned();
    $table->integer('device_id')->unsigned();
    $table->string('port', 5);
    $table->timestamps();

    $table->foreign('network_switch_id')->references('id')->on('network_switches')->onDelete('cascade');
    $table->foreign('device_id')->references('id')->on('devices')->onDelete('cascade');
});

My Port Associations file also had the following, which made it all connect as I expected:

public function device()
{
    return $this->belongsTo('\App\Device');
}

I also wound up creating a model that would allow me to flag a port as an "uplink" so it wouldn't show up when listing MAC address associations:

Schema::create('ports', function (Blueprint $table) {
    $table->increments('id');
    $table->string('port', 5);
    $table->integer('network_switch_id')->unsigned();
    $table->boolean('managed_uplink')->default(true);
    $table->string('description')->nullable();
    $table->integer('remote_switch_id')->unsigned()->nullable();
    $table->timestamps();

    $table->foreign('network_switch_id')->references('id')->on('network_switches');
    $table->foreign('remote_switch_id')->references('id')->on('network_switches');
});

I hope this helps someone else, it was super simple.

11 Feb
3 years ago

OneSeventeen started a new conversation Defining Tables That Will Bridge Other Tables

I am writing a very basic network documenting web app that will pull SNMP data from all of my switches, and possibly some LLDP data as well, to find out what devices are plugged in to each port on the switch.

There can be multiple devices per port, so I'm thinking of a layout similar to this:

  • Switch: ID, IP, Name (nullable), SNMP version (default: "v2"), SNMP community (default: "public"), description (nullable), location (nullable)
  • Device: ID, mac address (unique), description (nullable)
  • Device on Switch?: ID, mac address, switch ID

Actual use of the web app:

  1. I log in and see a list of switches
  2. I add a switch by typing the IP and SNMP community (--optional, default: "public") of a switch and clicking a shiny "Add Switch" button.
  3. My controller runs some SNMP queries against the switch and loops through the results adding a "Device on Switch" for each mac address on each port of the switch. It also updates the switch record itself with name, model, and location.
  4. Somehow a mac address will be added to the Device table if it doesn't already exist.
  5. The new switch will be added to the interface so I can click it to expand and view all the devices on each port. For ports that have multiple devices on them, I will simply display "n devices are on this port" with the option to expand and view those devices.

In the future:

I will later add IP address to the devices, as well as a device type (computer, switch, Access Point, printer, etc), DNS name, etc. which I will gather using other methods I haven't quite decided on yet.

My question:

Any thoughts on the best way to name/label my tables?

I really want to start this off as simple as possible, and I already have it generating the list of mac addresses and which port they are on, but I'm not storing the data or pulling configs from a database yet.

Thanks!