ChrisF79

ChrisF79

Member Since 6 Years Ago

Naples, FL

Experience Points
15,780
Total
Experience

4,220 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
174
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 4
15,780 XP
Aug
19
1 month ago
Activity icon

Replied to How Would I Create This Query Based On A Method I Have?

I don't see an example that applies.

Activity icon

Started a new Conversation How Would I Create This Query Based On A Method I Have?

I have a site I'm working on that will find music teachers near students. The student can look for teachers by choosing a distance from their address.

I have a method calculate() that will take two latitude/longitude coordinates and calcualte the distance between the two points. It works great.

How do I create a query that will find all of the teachers with lat/long within a distance from the student?

Thank you

Aug
09
1 month ago
Activity icon

Replied to How To Save To A Database With Multiple Tables?

Thank you so much for taking the time to write that up! It is greatly appreciated!

Aug
08
1 month ago
Activity icon

Replied to How To Save To A Database With Multiple Tables?

Ok, correct me if I'm wrong but it looks like I have to do this in two steps...

$user = new App\User;
$user->first_name = "Chris"
.
.
.
$user->save();

$address = new App\Address;
$address->address_1 = "123 Main Street"
.
.
.
$user->addresses()->save($address);
Activity icon

Started a new Conversation How To Save To A Database With Multiple Tables?

I have a Users table and an Address (mailing address) table and I have the relationships set up as such:

User Model

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];


    public function address()
    {
        return $this->hasMany('App\Address', 'user_id');
    }
}

User Migration

        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('first_name');
            $table->string('last_name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

Address Model

class Address extends Model
{
    public function address_type()
    {
        return $this->hasOne('App\AddressType');
    }

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

Address Migration

        Schema::create('addresses', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('address_type');
            $table->unsignedBigInteger('user_id');
            $table->string('address_1');
            $table->string('address_2')->nullable();
            $table->string('address_3')->nullable();
            $table->string('city');
            $table->string('state_or_province');
            $table->string('postal_code');
            $table->float('GoogleLat', 10, 8)->nullable();
            $table->float('GoogleLong', 10, 8)->nullable();
            $table->timestamps();
        });

How do I then save a new user with their address using eloquent?

I tried things like $user->address_1 or $user->address->address_1with no luck.

Aug
06
1 month ago
Activity icon

Replied to Unknown Column When Inserting Into A Polymorphic Schema

I see what I was missing. I need to:

$customer->save();

// then

$customer->telephonenumber()->create(['phone_number' => '(222) 555-3333']);

$customer->save();
Activity icon

Started a new Conversation Unknown Column When Inserting Into A Polymorphic Schema

I created a "telephonenumbers" table that will store many numbers for each "customer". However, when I try to insert I get an error that the column "phone_number" doesn't exist in the customers table. It doesn't... it's in the telephonenumbers table!

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    protected $guarded = [];

    public function address()
    {
        return $this->morphOne('App\Address', 'addressable');
    }

    public function telephonenumber()
    {
        return $this->morphOne('App\TelephoneNumber', 'telephonenumberable');
    }
}

In my TelephoneNumber.php class

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class TelephoneNumber extends Model
{
    protected $guarded = [];

    public function telephonenumberable()
    {
        return $this->morphTo();
    }
}

Then I try to insert:

$customer = new App\Customer;
$customer->first_name = "John";
$customer->last_name = "Doe";
$customer->company = "Doe a Deer";
$customer->title = "president";
$customer->website = "laracasts";
$customer->profile_img = "some/url/";

// here's where I'm stuck
$customer->phone_number = "(555) 111-2222";

$customer->save();

This results in:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'phone_number' in 'field list' (SQL: insert into `customers` (`first_name`, `last_name`, `company`, `title`, `website`, `profile_img`, `phone_number`, `updated_at`, `created_at`) values (John, Doe, Doe a Deer, president, laracasts, some/url/, (555) 111-2222, 2020-08-07 00:31:54, 2020-08-07 00:31:54))'
Aug
05
1 month ago
Activity icon

Started a new Conversation Should I Have One Address Table Or Two?

I'm creating a customer relationship manager (CRM) app so Realtors can manage their customers. The Realtors are the users of the site so they will be stored in the user table. Their customers can have multiple physical addresses (work, home, second home, etc) so they're going to be in an address table.

With that said though, the users of the site will also have addresses used for billing purposes. Do I create a second address table for them? I'm not sure how would be best to design this in MySQL.

Aug
04
1 month ago
Activity icon

Replied to Please Help Me Design This Database

What if someone owns 3 homes?

Activity icon

Started a new Conversation Please Help Me Design This Database

I'm creating a customer relationship management app. The users table will hold the users of the site. The site manages people so there will need to be a table for people. That said, how do I handle addresses? Someone may have two houses and therefore two mailing addresses. Do I then make an "addresses" table that's separate? And, if they have two addresses, do they then have two lines in the people table? How would you design it?

Jul
23
1 month ago
Activity icon

Replied to Trying To Get Property 'metainfo' Of Non-object

In my route web.php I have:

Route::get('/listing/{listing}/{metainfo?}', '[email protected]')->middleware(\App\Http\Middleware\PropertyUrlRedirect::class)->name('listing.show');

It has the metainfo from the URL I think (based on the error message) but I don't know what's missing or why.

Jul
22
1 month ago
Activity icon

Started a new Conversation Trying To Get Property 'metainfo' Of Non-object

Hi there,

I just upgraded to Laravel 7 from 6 and I'm getting the error:

ErrorException
Trying to get property 'metainfo' of non-object
http://listingnaples.com/listing/220043611/3325-airport-pulling-road-north-unit-q4-naples-fl-34105

The code that it refers to is:

<?php

namespace App\Http\Middleware;

use Closure;
use Redirect;

class PropertyUrlRedirect
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // Clean/self-updating URLs for property
        $route = $request->route();
        //dd($route);

        $listing = $route->parameter('listing');

        if ($route->parameter('metainfo') != $listing->metainfo) {
            return Redirect::route('listing.show', [$listing->MLSNumber, $listing->metainfo]);
        }

        return $next($request);
    }
}

It is complaining about the if statement toward the bottom. Why? I can't figure out why it is doing this or how to fix it.

Thank you!

Jul
21
1 month ago
Activity icon

Started a new Conversation How To Diagnose A Slow Site

Hi everyone,

I have a site at listingnaples.com and as you can see, it loads VERY slowly. How do I diagnose it and find out why? I am almost certain it is a database issue and a problem with a query but I'm not sure how I'd tell. Any suggestions are greatly appreciated!