dxladner

Member Since 4 Years Ago

Experience Points
22,290
Total
Experience

2,710 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
206
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.

  • Community Pillar

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

Level 5
22,290 XP
Apr
13
21 hours ago
Activity icon

Replied to Livewire And Laravel Relatioinships

Thanks @tykus for the clarification. I should have caught the Query Builder error, my bad. Thanks for the intro to the optional helper method.

Activity icon

Started a new Conversation Livewire And Laravel Relatioinships

Still learning Livewire. my question: Does Livewire work with Laravel Relationships? here is my example that is not working for me using Livewire.

App\Models\Ticket file status_id is the field in the ticket table for saving the id of the status.

public function status()
{
    return $this->hasMany(Status::class, 'status_id' );
}

I have also tried to leave out foreign key like this in the Ticket model file without success:

public function status()
{
    return $this->hasMany(Status::class);
}

App\Models\Status file

public function ticket()
{
   return $this->belongsTo(Ticket::class);
}

livewire\tickets.blade.php file

this of course works: I get the actual status_id value from the ticket table.

{{ $ticket->status_id }} 

But I am expecting to get the name field of status using the code below along with my relationships setup between tickets and status models.

{{  $ticket->status->name }} 

But I am getting error of :

Undefined property: stdClass::$status

here is my livewire component which sends this ticket data to the livewire blade file:

 public function render()
 {
        return view('livewire.tickets',[
            'tickets'   => DB::table('tickets')->where('author_id', '=', Auth()->user()->id)->get()
        ]);
 }

So it might be something else I have not done correctly in the Livewire component my relationships? But was also curious if Livewire worked with Laravel Relationships out the box without any issues.

Thanks!

Apr
02
1 week ago
Activity icon

Replied to Target Class Mail.manager Does Not Exist

somethings are really that easy :)

Thanks @neilstee

Apr
01
1 week ago
Activity icon

Started a new Conversation Target Class Mail.manager Does Not Exist

So I upgraded my Laravel app from 7 to 8 using the Laravel docs. Made all necessary changes and everything appeared to work. Then I found out that the Password Reset form, where users places their email address to get an email with a password reset link does not work. Since this is "out of the box" type Controller from Laravel, I never thought to check this.

I get the error Target class [mail.manager] does not exist.

Has anyone experienced this? From research, I found old answer for Laravel 5.2 to add Illuminate\Mail package but that is now included.

I also ran php artisan config:cache did not help.

My login and register functionality works fine. All other routes work fine.

Any suggestions?

Mar
05
1 month ago
Activity icon

Replied to Alpine JS Help In Blade File

Thanks TYKUS. Still new to Alpine, I figured there was a way.

Activity icon

Started a new Conversation Alpine JS Help In Blade File

Wondering if Alpine JS currently has a way to accomplish the following. Using Normal Blade file, "sprinkling" some Alpine JS in the file. Running a fetch call to get data on images data object. Looping over items work okay until I get to the "normal" Delete type setup. Does Alpine JS have a way when looping using the alpine template to insert the image id in the Laravel Blade url or route function?

the line I need to pass in the image id is the url function

<form class="form" style="display:flex;justify-content: center;" role="form" method="POST" action="{{ url('/admin/images/' . $image->id) }}">

full code block below

<div class="row"
                     x-data="{ images: [] }"
                     x-init="
                    fetch('http://cwrtn.test/api/images')
                    .then(response => response.json())
                    .then(data => images = data.data)
                    "
                >
                    <template x-for="image in images" :key="image.id">
                        <div class="media_block" style="border: 1px solid #1d2758;padding: 5px;display: flex; justify-content: center;">
                            <div class="media_blk_content">
                                <h5 x-text="image.imagename"></h5>
                                <img :src="image.image_url_path" width="50px;" />
                                <div>
                                    <form class="form" style="display:flex;justify-content: center;" role="form" method="POST" action="{{ url('/admin/images/' . $image->id) }}">
                                        <input type="hidden" name="_method" value="delete">
                                        {{ csrf_field() }}
                                        <button class="btn text-white bg-tmred btn-icon-split btn-sm" Onclick="return ConfirmDelete();">
                                                <span class="icon text-white-50">
                                                  <i class="fas fa-trash"></i>
                                                </span>
                                            <span class="text">DELETE</span>
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </template>
                </div>
Feb
15
1 month ago
Activity icon

Awarded Best Reply on AWS HTTP Error: CURL Error 60: SSL Certificate Problem

@dalma So I finally figured it out. I am using Mamp for Windows 10. So I downloaded the newest CA cert from here: https://curl.haxx.se/docs/caextract.html

Then since MAMP php.ini has the bare minimum setup, I had to add the openssl lines and point the files to my new certificate.

I placed the new certificate in this path: C:\MAMP\bin\php\php7.2.1\extras\ssl\cacert.pem

A lot of the documentation out there states to use this code snippet:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="C:\MAMP\bin\php\php7.2.1\extras\ssl\cacert.pem"

but this NEVER worked for me.

After added this code snippet to my version's php.ini file

[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile="C:\MAMP\bin\php\php7.2.1\extras\ssl\cacert.pem"

; If openssl.cafile is not specified or if the CA file is not found, the
; directory pointed to by openssl.capath is searched for a suitable
; certificate. This value must be a correctly hashed certificate directory.
; Most users should not specify a value for this directive as PHP will
; attempt to use the OS-managed cert stores in its absence. If specified,
; this value may still be overridden on a per-stream basis via the "capath"
; SSL stream context option.
openssl.capath="C:\MAMP\bin\php\php7.2.1\extras\ssl\cacert.pem"

and enable module by un-commenting out this line

extension=openssl

It now works from my local. My files are getting pushed over to DO Spaces.

Now I get to fight my production site on Cloudways.

Oct
26
5 months ago
Activity icon

Replied to Advanced Query Help

rodrigo.pedra

yes adjusting the typo from id to fileable_id did the trick.

  #items: array:2 [▼
    0 => {#1422 ▼
      +"id": 4
      +"first_name": "David"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"phone": "9876543210"
      +"created_at": "2020-10-20 20:00:52"
      +"updated_at": "2020-10-20 20:00:52"
      +"files": array:2 [▼
        0 => {#218 ▼
          +"id": 8
          +"filename": "4_sample-pdf.pdf"
          +"file_extension": "pdf"
          +"file_url_path": "10-2020/4_sample-pdf.pdf"
          +"fileable_id": 4
          +"fileable_type": "App\Tech"
          +"created_at": "2020-10-20 20:00:52"
          +"updated_at": "2020-10-20 20:00:52"
        }
        1 => {#1379 ▼
          +"id": 9
          +"filename": "4_sample-pdf-2.pdf"
          +"file_extension": "pdf"
          +"file_url_path": "10-2020/4_sample-pdf-2.pdf"
          +"fileable_id": 4
          +"fileable_type": "App\Tech"
          +"created_at": "2020-10-20 20:00:52"
          +"updated_at": "2020-10-20 20:00:52"
        }
      ]
    }
    1 => {#1395 ▼
      +"id": 5
      +"first_name": "Jackie"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"phone": "8172158600"
      +"created_at": "2020-10-20 20:01:23"
      +"updated_at": "2020-10-20 20:01:23"
      +"files": array:1 [▶]
    }
  ]
}

thanks so much for your help.

Activity icon

Replied to Advanced Query Help

Thanks to everyone that responded. First, I do have relationships set up. Here is what I currently have.

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

    public function techs()
    {
        return $this->belongsToMany(Tech::class);
    }

    public function files()
    {
        return $this->morphMany(File::class, 'fileable');
    }

class File extends Model
{
    protected $fillable = [ 'filename', 'file_extension', 'file_url_path', 'fileable_id', 'fileable_type' ];

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

class Tech extends Model
{
    protected $table = 'techs';

    protected $fillable = ['first_name', 'last_name', 'email', 'phone'];
    
    public function getFullNameAttribute()
    {
        return "{$this->first_name} {$this->last_name}";
    }

    public function files()
    {
        return $this->morphMany('App\File', 'fileable');
    }

    public function facilities()
    {
        return $this->belongsToMany(Facility::class);
    }
}

class User extends Authenticatable
{
    use Notifiable;

    protected $fillable = [
        'first_name', 'last_name', 'role', 'email', 'password',
    ];

    public function facility()
    {
        return $this->belongsTo('App\Facility', 'id', 'user_id');
    }

}

so mr-shahin, I tried that early using groupBy. It groups the techs but only gives one file per tech. So in this example David Smith has two files associated with him, but it only gives one.

$user_id = Auth::id();
$data = DB::table('facilities')->where('user_id', '=', $user_id)
            ->join('facility_tech', 'facilities.id', 'facility_tech.facility_id')
            ->join('techs', 'facility_tech.tech_id', 'techs.id')
            ->join('files', 'techs.id', 'files.fileable_id')
	    ->groupBy('techs.id')
            ->get();

dd
Illuminate\Support\Collection {#1428 ▼
  #items: array:2 [▼
    0 => {#1429 ▼
      +"id": 8
      +"name": "Feelgood ER"
      +"address_one": "123 Test"
      +"address_two": null
      +"city": "Test City"
      +"state": "texas"
      +"zip": "12345"
      +"phone": "9876543210"
      +"message": "Hello Feelgood ER, this is a test message."
      +"call_schedule_one_title": "Nov 2020 Call Schedule"
      +"call_schedule_one": "8"
      +"call_schedule_two_title": "Dec 2020 Call Schedule"
      +"call_schedule_two": "9"
      +"user_id": 2
      +"created_at": "2020-10-20 20:00:52"
      +"updated_at": "2020-10-20 20:00:52"
      +"facility_id": 1
      +"tech_id": 4
      +"first_name": "David"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"filename": "4_sample-pdf.pdf"
      +"file_extension": "pdf"
      +"file_url_path": "10-2020/4_sample-pdf.pdf"
      +"fileable_id": 4
      +"fileable_type": "App\Tech"
    }
    1 => {#1426 ▼
      +"id": 10
      +"name": "Feelgood ER"
      +"address_one": "123 Test"
      +"address_two": null
      +"city": "Test City"
      +"state": "texas"
      +"zip": "12345"
      +"phone": "8172158600"
      +"message": "Hello Feelgood ER, this is a test message."
      +"call_schedule_one_title": "Nov 2020 Call Schedule"
      +"call_schedule_one": "8"
      +"call_schedule_two_title": "Dec 2020 Call Schedule"
      +"call_schedule_two": "9"
      +"user_id": 2
      +"created_at": "2020-10-20 20:01:23"
      +"updated_at": "2020-10-20 20:01:23"
      +"facility_id": 1
      +"tech_id": 5
      +"first_name": "Jackie"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"filename": "5_sample-pdf.pdf"
      +"file_extension": "pdf"
      +"file_url_path": "10-2020/5_sample-pdf.pdf"
      +"fileable_id": 5
      +"fileable_type": "App\Tech"
    }
  ]
}

rodrigo.pedra

this one gives us two techs data only without any of their files. So yes, I am interested in techs and the files associated with them but I also need the rest of the tables I joined information. This results set does not return any techs files.

I am creating a Facility Dashboard. so when the user logins, it will see all of their facility data, along with any techs that are associated with the facility, and of course, that techs files.

Illuminate\Support\Collection {#1421 ▼
  #items: array:2 [▼
    0 => {#1422 ▼
      +"id": 4
      +"first_name": "David"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"phone": "9876543210"
      +"created_at": "2020-10-20 20:00:52"
      +"updated_at": "2020-10-20 20:00:52"
      +"files": []
    }
    1 => {#1395 ▼
      +"id": 5
      +"first_name": "Jackie"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"phone": "8172158600"
      +"created_at": "2020-10-20 20:01:23"
      +"updated_at": "2020-10-20 20:01:23"
      +"files": []
    }
  ]
}

when I start using Eloquent. I continued to have issues getting a techs files. for example.

$user_id = Auth::id();
$user = User::findOrFail($user_id);

$facility = $user->facility;   // this works, I get the facility data associated with the User
$techs = $facility->techs;  // this works since I have the $facility instance. It returns the 2 techs associated with the facility. 

$techfiles = $techs->files;   //  returns empty result set. I assume since $techs is a multiple results set, there are two different $techs in the result set. 

So then I moved to using the query builder as below. which gives me everything I need except the grouping option. It returns the 3 files in result sets. I need the result set to return all data, and return the 2 techs grouped together, and have their files results inside each tech.

  $user_id = Auth::id();
  $data = DB::table('facilities')->where('user_id', '=', $user_id)
            ->join('facility_tech', 'facilities.id', 'facility_tech.facility_id')
            ->join('techs', 'facility_tech.tech_id', 'techs.id')
            ->join('files', 'techs.id', 'files.fileable_id')
            ->groupBy('techs.id')
            ->get();
        dd($data);

Thanks again for everyones help!

Oct
25
5 months ago
Activity icon

Started a new Conversation Advanced Query Help

I have a query with multiple joins. The logged in User belongs to a facility. There is a pivot table for a many to many facility to tech relationship. Where a tech can belong to many different facilities and A facility can have many different techs. A tech can have multiple files attached to them.

  $user_id = Auth::id();
  $data = DB::table('facilities')->where('user_id', '=', $user_id)
            ->join('facility_tech', 'facilities.id', 'facility_tech.facility_id')
            ->join('techs', 'facility_tech.tech_id', 'techs.id')
            ->join('files', 'techs.id', 'files.fileable_id')
            ->get();
        dd($data);

Here is my dd

Illuminate\Support\Collection {#1428 ▼
  #items: array:3 [▼
    0 => {#1426 ▼
      +"id": 8
      +"name": "Feelgood ER"
      +"address_one": "123 Test"
      +"address_two": null
      +"city": "Test City"
      +"state": "texas"
      +"zip": "12345"
      +"phone": "9876543210"
      +"message": "Hello Feelgood ER, this is a test message."
      +"call_schedule_one_title": "Nov 2020 Call Schedule"
      +"call_schedule_one": "8"
      +"call_schedule_two_title": "Dec 2020 Call Schedule"
      +"call_schedule_two": "9"
      +"user_id": 2
      +"created_at": "2020-10-20 20:00:52"
      +"updated_at": "2020-10-20 20:00:52"
      +"facility_id": 1
      +"tech_id": 4
      +"first_name": "David"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"filename": "4_sample-pdf.pdf"
      +"file_extension": "pdf"
      +"file_url_path": "10-2020/4_sample-pdf.pdf"
      +"fileable_id": 4
      +"fileable_type": "App\Tech"
    }
    1 => {#1422 ▼
      +"id": 9
      +"name": "Feelgood ER"
      +"address_one": "123 Test"
      +"address_two": null
      +"city": "Test City"
      +"state": "texas"
      +"zip": "12345"
      +"phone": "9876543210"
      +"message": "Hello Feelgood ER, this is a test message."
      +"call_schedule_one_title": "Nov 2020 Call Schedule"
      +"call_schedule_one": "8"
      +"call_schedule_two_title": "Dec 2020 Call Schedule"
      +"call_schedule_two": "9"
      +"user_id": 2
      +"created_at": "2020-10-20 20:00:52"
      +"updated_at": "2020-10-20 20:00:52"
      +"facility_id": 1
      +"tech_id": 4
      +"first_name": "David"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"filename": "4_sample-pdf-2.pdf"
      +"file_extension": "pdf"
      +"file_url_path": "10-2020/4_sample-pdf-2.pdf"
      +"fileable_id": 4
      +"fileable_type": "App\Tech"
    }
    2 => {#1430 ▼
      +"id": 10
      +"name": "Feelgood ER"
      +"address_one": "123 Test"
      +"address_two": null
      +"city": "Test City"
      +"state": "texas"
      +"zip": "12345"
      +"phone": "8172158600"
      +"message": "Hello Feelgood ER, this is a test message."
      +"call_schedule_one_title": "Nov 2020 Call Schedule"
      +"call_schedule_one": "8"
      +"call_schedule_two_title": "Dec 2020 Call Schedule"
      +"call_schedule_two": "9"
      +"user_id": 2
      +"created_at": "2020-10-20 20:01:23"
      +"updated_at": "2020-10-20 20:01:23"
      +"facility_id": 1
      +"tech_id": 5
      +"first_name": "Jackie"
      +"last_name": "Smith"
      +"email": "[email protected]"
      +"filename": "5_sample-pdf.pdf"
      +"file_extension": "pdf"
      +"file_url_path": "10-2020/5_sample-pdf.pdf"
      +"fileable_id": 5
      +"fileable_type": "App\Tech"
    }
  ]
}

The issue is the results return an array of 3 results since there are three file. But I need the result set to return an array of 2 techs and inside each tech array is all of the data along with an array of their files.

So in this example: this facility has 2 Techs attached to them. David Smith has 2 files attached Jackie Smith has 1 files attached.

So I need it to return 2 techs and inside each tech is their array of file/files.

Thanks in advance!