daugaard47

daugaard47

Member Since 1 Year Ago

Experience Points
15,010
Total
Experience

4,990 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
134
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.

Level 4
15,010 XP
Oct
05
1 week ago
Activity icon

Replied to How To Push A GIT Branch To A Live Testing Server

Seems like the best flow is creating a master branch and a develop branch approach.

Develop branch would then push to staging server.

Develop branch can also have multiple branches: IE feature/newfeature branch

Once feature/newfeature branch is good on local;

  • merge to develop.
  • Then push develop to staging server to test live or to show client new feature(s)
  • After that, merge develop to master and push to production.

Looks like Gitflow has some helpful commands to make this process a little smoother.

Oct
03
1 week ago
Activity icon

Replied to How To Push A GIT Branch To A Live Testing Server

On my server In /var/repo/dev.git/hooks/post-receive I have the following:

git --work-tree=/var/www/dev --git-dir=/var/repo/dev.git checkout -f

This is what I use to push my master to live development server. Git push staging

Do I need to change this post-receive hook?

Activity icon

Started a new conversation How To Push A GIT Branch To A Live Testing Server

As the title states, I want to figure out a workflow to test my GIT Branches on a Live server before merging to master and pushing to production.

This is my current GIT Workflow:

I should note on my server the repo's are in /var/repo/dev.git and /var/repo/site.git and sync to my /var/www/(dev & site folder)

Here is the folder structure:

folder stucture

Inside dev.git and site.git

#HEAD
ref: refs/heads/master
---------
#CONFIG:
[core]
    repositoryformatversion = 0
    filemode = true
    bare = true

Inside the folder refs there is a folder called heads and a file called master. There are also other files that are named the same name as my branches I've tried to push.

branches

For simple changes:

  1. I work directly on the Master Branch, Locally.
  2. Then Push to a Live Staging server dev.example.com to make sure everything is running smooth
  3. Then push the master to the Live Production server example.com
git status
git add *
git commit -m "My Change"
git push // Pushes to Master Branch on Git Hub
git push staging // Pushes to my live staging server
git push production // Pushes to my live production server

For Branches:

  1. I create a new branch locally git checkout -b newbranch.

  2. Then Push to newly created branch on GitHub git push origin newbranch

  3. When on the newbrach I push to GitHub then try and push to git push staging or git push staging newbranch, but no changes are made to my staging/dev server

  4. So I have to git everything working on that branch locally

  5. Merge to the Master Branch

  6. Then push to Staging and hope all is working smoothly

  7. The push to Production

I want to figure out how to Push my working branch to my Live staging server so I can run Live Tests. Then Merge to Master and Push to Production.

Here is a nice little diagram of what I'm currently doing and what I want to do.

Note, I want to do illustration #3 in the diagram. enter image description here

Sep
27
2 weeks ago
Activity icon

Replied to Refactor If Statement

@lvismer Thank you! Both solutions worked. I opted for your first one. I appreciate your time.

Activity icon

Replied to Refactor If Statement

Should have mentioned... I have a Roles Table. Here is the Role Model:

class Role extends Model
{
    protected $table = 'roles';
    protected $fillable = [
        'name',
        'description',
            
    ];

    public function users()
    {
        return $this->hasMany('App\User', 'role_id', 'id');
    }
}

Here is the User Model

    public function role()
    {
        return $this->hasOne('App\Role', 'id', 'role_id');
    }

    public function hasRole($roles)
    {
        $this->have_role = $this->getUserRole();
        // Check if the user is a root account
        if($this->have_role->name == 'Root') {
            return true;
        }
        if(is_array($roles)){
            foreach($roles as $need_role){
                if($this->checkIfUserHasRole($need_role)) {
                    return true;
                }
            }
        } else{
            return $this->checkIfUserHasRole($roles);
        }
        return false;
    }
    
    private function getUserRole()
    {
        return $this->role()->getResults();
    }
    
    private function checkIfUserHasRole($need_role)
    {
        return (strtolower($need_role)==strtolower($this->have_role->name)) ? true : false;
    }

Activity icon

Started a new conversation Refactor If Statement

I'm displaying my users in my admin section and have created some Roles.

I'm storing the Roles as integers, so when I output the users role they show as numbers. I created a super long If statement like this to output the correct role name.

What's / Is there a better way to do this?

(FYI this is in my blade file)

@if($user->role_id === 0)
    Member
@elseif($user->role_id === 1)
    Super Admin
@elseif($user->role_id === 2)
    Admin
@elseif($user->role_id === 3)
    Moderator
@elseif($user->role_id === 4)
    Editor
@elseif($user->role_id === 5)
    Role X
@elseif($user->role_id === 6)
    Role Y
@elseif($user->role_id === 7)
    Role Z
@endif

Here is my basic controller function: (If Needed)

    public function adminUserIndex(){
        $users = User::orderBy('id', 'desc')->get();
        return view('admin.user.index',compact('users'));
    }

Sep
25
3 weeks ago
Activity icon

Replied to S3 File Manager

Yeah that's fine for me... Working out of the AWS console, but the rest of the team is use to services like Dropbox or Google Drive etc...

Basically wanting to make a community bucket for the team where we can place all our docs, images etc.. into it and add it to my admin panel for easy access for all team members.

Looking for a UI similar to Dropbox so they still have all the features they know and love.

Actually found this front-end last night. Laravel-Media-Manager

It hooks up to plank/laravel-mediable

Haven't had time to test yet, but if good, I'll share my results. In the meantime if you or anyone else knows of a better solution I would appreciate any tips.

Sep
24
3 weeks ago
Activity icon

Started a new conversation S3 File Manager

Does anyone know of a good file manager built on top of Laravel?

I'm working for a non-profit and we recently started using AWS S3 for our image/file storage and I would like a File Manager similar to Dropbox where we can Search by folder/file name, show thumbnails of the images and upload.

I know I could make this myself with spatie/media-manager, but I'm the only dev and don't have time at the moment. Wouldn't mind a paid for solution if available.

I've found this package that's pretty close (Missing Search function):

Simply looking for something with everything out-of-the-box and ready to go.

Sep
20
3 weeks ago
Activity icon

Replied to Use A Dynamic URL In Blade Style Barryvdh/laravel-dompdf

@snapey Yeah I realized that typo, but still didn't do the trick. After reading through the issues on the github page for barryvdh/laravel-dompdf it's seems like a know issue and it needs the servers absolute path.

"For anyone who wants the answer simply, just change your image path in your view for pdf'ing from src="images/image.jpg" to src="/var/www/site/images/image.jpg" basically you gotta use the full path on a server even a local one then you will be good to go. If you are doing a local host on windows then you need to use c://folder/folder/etc and the same for Mac Applications/website/folder/etc" CallumEddisford

Link to thread

Others mention doing the following:

<?php echo $_SERVER["DOCUMENT_ROOT"].'/public/images/topo.jpg'; ?>

Still not sure why public_path or storage_path wouldn't work.

Still didn't solve the main issue, but ended up just hard coding in the image link from the production site for the time being.

PDF generation is a strange beast.

Activity icon

Started a new conversation Use A Dynamic URL In Blade Style Barryvdh/laravel-dompdf

I'm generating a PDF via:

laravel-dompdf

I can't seem to get the dynamic URLs to work.

Example: Inside my blade file I have inline style setup like so and I need the background image to be a full path:

<style>
.cardbg{
background: url('https://examplesite.com/images/pic.jpg')
}
I've tried the following variations with no luck. I don't understand why this is not working.
        background: url({{asset('/images/pic.jpg')}});
        background: url({{public_path('/images/pic.jpg')}});
        background: url({{storage_path('/images/pic.jpg')}});
        background: url({{config('app.url').'/images/pic.jpg'}});

</style>

I did get the full path to render correctly outside the <style> tags by doing this:

<img  src="{{public_path("/storage/images/folder/$var->example/profile-img/$var->img_name")}}">

Note: asset and storage_path did not work either.

Any help would be appreciated.

Sep
11
1 month ago
Activity icon

Commented on Install PHP, MySQL And Composer

+1 on Laragon!

Aug
21
1 month ago
Activity icon

Replied to Passing Auth User Data To Queue Job Class

Got it.

$pdfUserEmail = $this->pdfUser->email;
$pdfUserName = $this->pdfUser->first_name;
Activity icon

Started a new conversation Passing Auth User Data To Queue Job Class

I've created a job that processes PDFs in the background. I would like to fire off an email to the Auth user once the job is complete with a link to download the newly generated PDF.

Here is what I'm currently doing.

Controller:

        public function haitiKidPdfAll(){
            $pdfUser = User::find(Auth::user()->id);
            $haitiKids = Kid::
            whereRaw('sponsors_received < sponsors_needed')
            ->where('current_country', 'Haiti')
            ->orderBy('sponsors_received', 'ASC')
            ->get();

            ProcessPdfHaiti::dispatch($haitiKids,$pdfUser);
            return back()->with('info','This will take a couple minutes. I\'ll email you when it\'s completed.');

ProcessPdfHaiti Job:

Get Error Here: Undefined variable: pdfUser {"exception":"[object] (ErrorException(code: 0): Undefined variable: pdfUser at line 53. which is $pdfUserEmail = $pdfUser->email; In the code below.

class ProcessPdfHaiti implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $haitiKids;
    public $pdfUser;

    public function __construct($haitiKids,$pdfUser)
    {
        $this->haitiKids = $haitiKids;
        $this->pdfUser = $pdfUser;
    }

    public function handle()
    {
          
        ...PDF Query Stuff

        $pdfUserEmail =  $pdfUser->email;
        $pdfUserName =  $pdfUser->first_name;

        //I WANT TO EMAIL THE AUTH USER HERE!!! Then Pass the Auth Users Name to the email.
        Mail::to($pdfUserEmail)
        ->send(new PdfFinished(
            $pdfUserName = $pdfUserName,
            ));
    }
}

MAILABLE:

class PdfFinished extends Mailable
{
    use Queueable, SerializesModels;
 
    public $pdfUserName;
    public $pdfpath;

    public function __construct($pdfUserName,$pdfpath)
    {
        $this->pdfUserName =$pdfUserName;
        $this->pdfpath =$pdfpath;
    }

    public function build()
    {
        return $this->subject('PDF Has Completed')->markdown('emails.staff.pdfcompleted');
    }
}

EMAIL TO AUTH USER:

@component('mail::message')
### Hello {{ $pdfUserName }},<br>
..etc
@endcomponent

Been at this for days. Any help would be appreciated.

Aug
08
2 months ago
Activity icon

Replied to How To Output A Json Array And Loop Through Variables

Sweet that worked. Thank you for the help. Really appreciate it. So I guess I was already passing in the encoded Json and it was being outputted as an array. Was that the issue?

Activity icon

Replied to How To Output A Json Array And Loop Through Variables

If I do a dd on $guest in the NewGalaTransactions public function __construct I get the following. In this case I added 2 Guests. Looks like its passing an array:

array:2 
[ 
0 => array:3 
[ "no" => 1 "guest_name" => "John Doe" "gluten" => "No" ] 
1 => array:3
 [ "no" => 2 "guest_name" => "Jane Doe" "gluten" => "Yes" ] 
]
Activity icon

Replied to How To Output A Json Array And Loop Through Variables

Its an API controller. I'm using Vue to collect the data and then I pass that to my database via axios.

Activity icon

Replied to How To Output A Json Array And Loop Through Variables

If I remove the $array = json_encode($guest)

I get the error Trying to get property 'guest_name' of non-object

Markdown:

- Guests: 
@foreach ($guests as $item)
{{ $item->guest_name  }} | {{ $item->gluten  }}
@endforeach
Activity icon

Replied to How To Output A Json Array And Loop Through Variables

In my Controller I have this:

                for ($i = 1; $i <= 7; $i++) {
                    $currentGuest = 'guest' . $i;
                    $currentGuestGluten = 'guestgluten' . $i;
                    $guests['guest' . $i] = [
                        'no' => $i,
                        'name' => $galaUser ? $galaUser->$currentGuest : null,
                        'gluten' => $galaUser ? $galaUser->$currentGuestGluten : null
                    ];
                }

Then

        return response()->json([
            ...
            'guests' => $guests,
            ...
        ]);
Activity icon

Replied to How To Output A Json Array And Loop Through Variables

That's what I started out with and I also get Invalid argument supplied for foreach() I really don't know why that doesn't work.

$guests is [{"no":1,"guest_name":"John Doe","gluten":"Yes"}]

Activity icon

Replied to How To Output A Json Array And Loop Through Variables

When I remove the is_array($array) I get the error Invalid argument supplied for foreach()

This is my code now:

@php
$array = json_encode($guests);
@endphp


- Guests: 
@if(!empty($array)  && isset($array))
@foreach ($array as $item)
{{ $item->guest_name  }} | {{ $item->gluten  }}
@endforeach
@endif

Activity icon

Started a new conversation How To Output A Json Array And Loop Through Variables

I have a small ticket app on my site where users can buy tickets and add guests. I'm sending out the Receipt Email and need to display the guest names.

Note, There can be up to 7 guests.

The Guest are in an array. How can I display the guests properly in the email?

Here is what I'm working with.

Email:

@php
$array = json_encode($guests);
@endphp

@component('mail::message')
# Greetings,...

## Here is an outline of your transaction:
@component('mail::panel')
...
- Guests: @if(!empty($array)  && isset($array)  && is_array($array))
@foreach ($array as $item)
{{ $item->guest_name  }} | {{ $item->gluten  }}
@endforeach
@endif
@endcomponent

The array at the top, wrapped in the PHP Tags outputs the following data:

[{"no":1,"guest_name":"John Doe","gluten":"Yes"}]

I'm currently not getting any errors to debug, but I'm not getting anything outputted in the email either.

I'm using Laravel so here is my Mail File: I tried writing the logic in here as well, but same results.

<?php

namespace App\Mail;

use ...

class NewGalaTransaction extends Mailable
{
    use Queueable, SerializesModels;
    public ...
    public $guests;

    public function __construct(
            $...
            $guests
    )
    {
            $...
            $this->guests = $guests;
            // $this->guests = json_encode($guests);
    }

    public function build()
    {
        return $this->subject('Order Email')->markdown('emails.user.newGalaTransactionEmail');
    }
}

Any help would be appreciated.

Apr
24
5 months ago
Activity icon

Replied to Radial Progress Bar

Still would like to know how Jeffery does it though.

Activity icon

Replied to Radial Progress Bar

Got this fully working. I'll just leave this here in case in might help someone. https://codepen.io/daugaard47/pen/OGBbBK

HTML: The data-percent controls the stroke fill. This could be replaced with a dynamic value.

<div class="flex justify-center mt-10">
  <div class="w-1/2">
    <div class="svgbox">
      <div class="progressdiv" data-percent="75"> 
        <svg class="progress" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="50" fill="transparent" stroke-dasharray="314.159" stroke-dashoffset="0" ></circle>
  <circle class="bar" cx="50" cy="50" r="50" fill="transparent" stroke-dasharray="314.159" stroke-dashoffset="0"></circle>
        </svg>
        <img src="https://www.okayplayer.com/wp-content/uploads/2015/07/Barack-Obama-House-Music-Square.jpg" class="rounded-full absolute left-0 top-0" style="width: 92%;left: 50%; top:50%; transform: translate(-50% , -50%);">
      </div>
    </div>
  </div>
</div>

CSS:

body {
  background-color: #1e2d47;
}

.progress {
  display: block;
  margin: 0 auto;
  overflow: visible;
  transform: rotate(-90deg) rotateX(180deg);
}

.progress circle {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s ease;
  stroke: #f5f5f5;
  stroke-width: 2px;
}

.progress .bar {
  stroke: #d66f6f;
}

.progressdiv {
  position: relative;
}

.svgbox {
  height: 0; /* collapse the container's height */
  width: 100%; /* specify any width you want (a percentage value, basically) */
  /* apply a padding using the following formula */
  /* this formula makes sure the aspect ratio of the container equals that of the svg graphic */
  padding-top: (svg height / svg width) * width-value;
  position: relative; /* create positioning context for svg */
}

/* Adds Text to center*/
/* .progressdiv:after {
  position: absolute;
  top: 50%;
  left: 50%;
 
  font-size: 35px;
  transform: translate(-50%, -50%);
  content: attr(data-percent) " %";
} */


JS:

(function() {
  window.onload = function() {
    var totalProgress, progress;
    const circles = document.querySelectorAll(".progress");
    for (var i = 0; i < circles.length; i++) {
      totalProgress = circles[i]
        .querySelector("circle")
        .getAttribute("stroke-dasharray");
      progress = circles[i].parentElement.getAttribute("data-percent");

      circles[i].querySelector(".bar").style["stroke-dashoffset"] =
        totalProgress * progress / 100;
    }
  };
})();
Apr
23
5 months ago
Activity icon

Started a new conversation Radial Progress Bar

Is there a tutorial on Laracasts based on how to build a Radial progress bar, exactly like the ones on this website? If not here, anywhere else? Would like to use it in a project for a fundraiser to show the status of donations.

Apr
19
5 months ago
Activity icon

Started a new conversation Laravel And Vue - MPA (Multiple Page Application)

-1. I'm trying to learn Vue with Laravel. I did the latest SPA course on Laracast and the vue-router seemed pretty easy to use, and was wonderful for a SPA, but what about larger application.

Example: I currently have a website I built with Laravel and I have around 50+ web routes. If I was to take on a new project similar to this, would I stick with the routes/web.php routes or move all routes to vue-router?

-2. I understand that Vue is a Front-end Framework on its own, but Does Vue ship with Laravel to help extend the blade/view files?

Is Vue in Laravel only meant to bring in components on an as needed basis. Similar to how jQuery is used? e.g: I need a slider on one of my pages/views. "Okay, build it as a component with Vue and drop it in".. Is that how I should look at Vue in Laravel?

-3. Would it be safe to say the best way to use Vue and Laravel on large project is by separating the two? Use Laravel as your API and Vue to build your front-end.

Just trying to understand how to correctly use Vue in Laravel. Any thought on this would be appreciated. Maybe I missed the course on this site. A link to that would be helpful as well.

Mar
24
6 months ago
Activity icon

Replied to How To Setup My Laravel Project In Digitalocean?

@harendrasingh Did you figure this out? If not, let me know and I'll post how to do it manually.

Mar
12
7 months ago
Activity icon

Started a new conversation Sending Markdown Emails

I have a feature on my site similar to a contact form, but I'm using it so a Sponsor can send a letter to their Sponsored Child. I wanted to use Markdown emails rather than plan html.

I currently have this working with no issues, but seems like it was way to much work and thought that there had to be an Easier Way.

If anyone could review and give me some pointers that would be great.

Route:

Route::post('/email/letter', '[email protected]')->name('sponsorLetterPost');

Form:

<form enctype="multipart/form-data" action="{{ route('profile.sponsorLetterPost') }}" method="post">
        @csrf
    //Name (Pre-Populated)
    <input type="text" value="{{ $user->first_name.' '.$user->last_name }}" name="name">
    //Email (Pre-Populated)
    <input type="text" value="{{ $user->email }}" name="email">
    //Letter/Message
    <textarea type="text" placeholder="Type your letter here" name="smessage"></textarea>
    // Hidden Field
    <input type="hidden" name="subject" value="Letter to {{ $name }}">
    <input type="hidden" name="child_cin" value="{{ $kid->kid->cin }}">
    <input type="hidden" name="child_name" value="{{ $name }}">
    <input type="hidden" name="child_age" value="{{ $kid->kid->age }}">
    <input type="hidden" name="child_gender" value="{{ $kid->kid->gender }}"> 
    <input type="hidden" name="child_location" value="{{ $kid->kid->current_town.','.' '.$kid->kid->current_country }}">
    <button type="submit">Send Letter</button>
</form>

Controller:

    public function sponsorLetterPost(Request $request)
    {
          $data = array(
            'name' =>Purifier::clean($request->name),
            'email' =>Purifier::clean($request->email),
            'smessage' =>Purifier::clean($request->smessage),
            'subject' =>$request->subject,
            'child_cin' =>$request->child_cin,
            'child_name' =>$request->child_name,
            'child_age' =>$request->child_age,
            'child_gender' =>$request->child_gender,
            'child_location' =>$request->child_location,
            );
          Mail::to('[email protected]')
          ->send(new \App\Mail\SponsorLetter(
            $request->input('name'),
            $request->input('email'),
            $request->input('smessage'),
            $request->input('subject'),
            $request->input('child_cin'),
            $request->input('child_name'),
            $request->input('child_age'),
            $request->input('child_gender'),
            $request->input('child_location')
          ));
          return back()->with('success','Your letter has been sent.');
      }

Mail SponsorLetter:

class SponsorLetter extends Mailable
{
    use Queueable, SerializesModels;
    public $name;
    public $email;
    public $smessage;
    public $subject;
    public $child_cin;
    public $child_name;
    public $child_age;
    public $child_gender;
    public $child_location;
 
    public function __construct( $name, $email, $smessage,$subject, $child_cin, $child_name,$child_age,$child_gender,$child_location)
    {
            $this->name = $name;
            $this->email =Purifier::clean($email);
            $this->smessage =Purifier::clean($smessage);
            $this->subject =$subject;
            $this->child_cin =$child_cin;
            $this->child_name =$child_name;
            $this->child_age =$child_age;
            $this->child_gender =$child_gender;
            $this->child_location =$child_location;
    }
    /**
     * Build the message.
     *
     * @return $this
     */

    public function build()
    { 
        return $this->markdown('emails.staff.sponsorletter');
    }
}

Markdown Email Sponsorletter:

@component('mail::message')
### Hello,<br>{{ ucfirst(strtolower($name)) }} has sent a letter to {{ ucfirst(strtolower($child_name)) }}<br>

###**Sponsored Child Info:**
@component('mail::panel')
- **Child ID Number:** {{$child_cin}}
- **Child Name:** {{ ucfirst(strtolower($child_name)) }}
- **Child Age:** {{$child_age}}
- **Child Gender:** {{$child_gender}}
- **Child Location:** {{$child_location}}
@endcomponent

###**Sponsor Info:**
@component('mail::panel')
- **Sponsor Name:** {{ ucfirst(strtolower($name)) }}
- **Sponsor Email:** {{$email}}
@endcomponent

###**Sponsor Letter:**
@component('mail::panel')
{!! nl2br ($smessage) !!}
@endcomponent

 
Thank You,<br>
*- The {{ config('app.name') }}, Notifier*
@endcomponent
Feb
19
7 months ago
Activity icon

Replied to Filter Multiple Results From Database In View

@JLRDW - I get it. It's hard and takes time to learn. I need to hire a developer to help me now. Thanks for your help. Will definitely come back to this and learn it correctly, but need a solution now.

Activity icon

Replied to Filter Multiple Results From Database In View

@jlrdw Can you reach out to me at daugaard47@gmail.com Would like to speak with you directly if you don't mind. Thanks

Feb
18
7 months ago
Activity icon

Replied to Filter Multiple Results From Database In View

@JLRDW - So basically, am I almost there..? Just need to figure out how to return the return Response::json($value) ? I've literally been trying to figure this out for 2 days now. If you could help me fix my code up I would greatly appreciate it.

Activity icon

Replied to Filter Multiple Results From Database In View

@JLRDW - Okay I'm getting closer I think.

Routes:

    Route::get('/child-sponsorship','[email protected]')->name('child-sponsorship');
    Route::get('/child-sponsorship/filter','[email protected]')->name('child-sponsorship-filter');

Index View (Show filter form and sponsor children)

                 <form id="myForm">
                                <label>Location</label>
                                <select id="location" name="location">
                                    <option value="">No Preference</option>
                                    @foreach ($country as $c)
                                    <option value="{{$c->country_name}}">{{$c->country_name}}</option>
                                    @endforeach
                                </select>

                                <label>Gender</label>
                                <select id="gender" name="gender">
                                    <option value="">No Preference</option>
                                    <option value="Male">Male</option>
                                    <option value="Female">Female</option>
                                </select>

                                <button id="ajaxSubmit">Filter Results</button>
                </form>
    @foreach ($sponsorKid as $sk)
    ////.......
    @endforeach 
-----------------------------------------------------
// JS

@section('filter_js')

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script>
   jQuery(document).ready(function(){
    jQuery('#ajaxSubmit').click(function(e){
     e.preventDefault();
     $.ajaxSetup({
      headers: {
          'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
      }
  });
     jQuery.ajax({
        url: "{{ route('child-sponsorship-filter') }}",
        method: "get",
        data: {
           location: jQuery('#location').val(),
           gender: jQuery('#gender').val(),
       },
       success: function(result){
           console.log(result);
       }});
 });
});
</script>
@endsection

According to my Debug bar tool I'm getting the correct query:

select * from `kids` where `current_country` = 'Nepal' and `gender` = 'Female' order by `id` asc

But it is NOT showing correctly on the page....? I'm also getting the correct path in my console:

jquery.min.js:19 XHR finished loading: GET "http://xxxxxx.oo/child-sponsorship/filter?location=Nepal&gender=Female".

What am I doing wrong here?

These are my 2 functions in KidController (index and filter)

        public function index(){ 

        $country = DB::table('countries')->distinct('country_name')->orderBy('country_name')->get();
        $sponsorKid = Kid::distinct()->orderBy('first_name')->get();
        return view('child-sponsorship.index',compact('sponsorKid','country'));
    } 

        public function filter(Request $request){ 
             $location = $request->location;
            $gender = $request->gender;
 
        $country = DB::table('countries')->orderBy('country_name')->get();
        if(empty($gender) && empty($location)){
            $sponsorKid = Kid::orderBy('id')->get();
        }elseif(!empty($gender) && !empty($location)){
           $sponsorKid = DB::table('kids')->where('current_country', $location)->where('gender', $gender)->orderby('id')->get(); 
        }elseif($gender != true){
            $sponsorKid = DB::table('kids')->where('current_country', $location)->orderby('id')->get();
        }elseif($location != true){
            $sponsorKid = DB::table('kids')->where('gender', $gender)->orderby('id')->get();
        }else{
            $sponsorKid = Kid::orderBy('id')->get();
        }
        return view('child-sponsorship.index',compact('sponsorKid','country'));

    }

I'm returning the same view as I don't want it to refresh to a new page.

Activity icon

Replied to Filter Multiple Results From Database In View

So I've been trying to figure this out. I got it to filter with Location & Gender By doing the following:

On my Filter form

  <form action="{{ route('child-sponsorship-filter') }}" method="get">
  @csrf
    Location
            <select name="location">
              <option value="">No Preference</option>
                @foreach ($country as $c)
              <option value="{{$c->country_name}}">{{$c->country_name}}</option>
                @endforeach
            </select>
        
        
          Gender
            <select name="gender">
              <option value="">No Preference</option>
              <option value="Male">Male</option>
              <option value="Female">Female</option>
            </select>
        
                <button type="submit">Filter Results</button>
            
  </form>

On my KidController

    public function index(){
            $country = DB::table('countries')->orderBy('country_name')->get();
            $sponsorKid = Kid::orderBy('first_name')->get();
            return view('child-sponsorship.index',compact('sponsorKid','country')); 
    }


    public function filter(Request $request){
            $location = $request->location;
            $gender = $request->gender;
            // $filter = [$location->location, $gender->gender];
            //dd($location);
        
        $country = DB::table('countries')->orderBy('country_name')->get();

        if(empty($gender) && empty($location)){
            $sponsorKid = Kid::orderBy('id')->get();
        }elseif(!empty($gender) && !empty($location)){
           $sponsorKid = DB::table('kids')->where('current_country', $location)->where('gender', $gender)->orderby('id')->get(); 
        }elseif($gender != true){
            $sponsorKid = DB::table('kids')->where('current_country', $location)->orderby('id')->get();
        }elseif($location != true){
            $sponsorKid = DB::table('kids')->where('gender', $gender)->orderby('id')->get();
        }else{
            $sponsorKid = Kid::orderBy('id')->get();
        }
        return view('child-sponsorship.index',compact('sponsorKid','country')); 
    }

Kids Table

+----+------------+--------+-----------------+
| id | first_name | gender | current_country |
+----+------------+--------+-----------------+
|  1 | Emma       | Female | Haiti           |
|  2 | Lea        | Female | Nepal           |
|  3 | Matthew    | Male   | India           |
|  4 | Andrew     | Male   | Nepal           |
|  5 | CHRIS      | Male   | Haiti           |
+----+------------+--------+-----------------+

Countries Table

+----+--------------+
| id | country_name |
+----+--------------+
|  1 | Haiti        |
|  2 | India        |
|  3 | Nepal        |
+----+--------------+

Routes in use

Route::get('/child-sponsorship','[email protected]')->name('child-sponsorship');
Route::get('/child-sponsorship/filter','[email protected]')->name('child-sponsorship-filter');

ISSUES

  1. Do to the @csrf in the form I get the token in the URL. How can I remove that?
  2. After selecting a filter: For example: Location, Haiti. I can't seem to get the current filter to stay in place on the select box after page refresh. It returns back to it's default state after page refresh.
  3. Can someone show me how I can update the filters via ajax without the page refresh.
Feb
15
8 months ago
Activity icon

Replied to Filter Multiple Results From Database In View

Pretty solid advice. I've been putting off learning Vue for some time now. Guess it might be a good time to dive into it. Thanks for the quick response.

Activity icon

Started a new conversation Filter Multiple Results From Database In View

I currently have a user table full on info 'birthday', 'gender','state', etc... and I want to learn how to create a dropdown selections to filter the results shown to users.

Almost exactly like this sponsor website by: World Vision

They allow users to filter the results by LOCATION, GENDER, AGE, BIRTH MONTH, BIRTH DAY

Are there any courses on here or any other good tutorials that teach this from start to finish / back-end to front-end? Would like to do this with Ajax so there is no page reload too.

Any tut suggestions or examples would be great.

Note I've seen a few Laravel packages for this on Github, but would like to learn without a package unless someone strongly recommends one. Thank you!

Feb
11
8 months ago
Activity icon

Replied to Combined First And Last Name

@CRONIX - Nice solution! Appreciate the help.

Activity icon

Started a new conversation Combined First And Last Name

Simple question and probably a simple answer, but I cannot seem to figure out how to add the First name and Last name of a user to 1 bracket command in the view.

Looking for something like this:

{{$team->first_name, $team->last_name}}

Is there a way to do this? OR do I always have to do it the long way?

{{$team->first_name}} {{$team->last_name}}
Feb
06
8 months ago
Activity icon

Replied to Add Elements Based On Database Column Number Value

@snapey Thank you that code liked helped alot. What does the $i represent?

Here is what I came up with:

@foreach(range(0,$sk->sponsors_needed--) as $i)
  @if($sk->sponsors_needed = $sk->sponsors_needed--)
    @if($sk->sponsors_needed < $sk->sponsors_received++)
      <span class="circ" align="center"></span>
    @else
      <span class="circ circ-outline" align="center"></span>
    @endif
  @endif
    @php $sk->sponsors_received--; $sk->sponsors_needed--; @endphp
@endforeach

All is working, but I'm getting my received sponsor dots in the right-to-left order rather left-to-right. Do you know how I can change the order?

Example:

  • Sponsors_Needed = ○ (Outlined dot)
  • Sponsors_Received = • (Filled dot)

So when I have:

  • Needed: 3
  • Received 2

My order is coming out like this:

○ • • 
(Needed, Received, Received)

I would like the opposite order:

• •  ○ 
(Received, Received, Needed)

Any thought on how to change the ordering?

Thanks for the help!

Activity icon

Started a new conversation Add Elements Based On Database Column Number Value

I'm running a foreach loop inside my view. In that loop I have a numeric column called Slots_Needed. Each Slots_Needed can have up to 10 slots, but I'll use 3 slots total in this example.

I would like each slot to be represented by a graphic Dot. 3 slots = • ?

What would be a shorter way to write this? I'm doing it like this now:

        @if($sk->slots_needed == 1)
          <span class="dot"></span>

        @elseif($sk->slots_needed == 2)
          <span class="dot"></span>
          <span class="dot"></span>

        @elseif($sk->slots_needed == 3)
          <span class="dot"></span>
          <span class="dot"></span>
          <span class="dot"></span>
        @endif
etc.....

Also, I have another column in the database called slots_ received. This holds a numeric value as well. How would I add the call dot-fill to the slots that have received dots? I'm very new to JS but it would probably involve an if statement of some sort adding a class that matched the value of slots_received. I appreciate any help. Thanks!

Jan
26
8 months ago
Activity icon

Replied to Free Domain Emails

@STEVECOVE - Thanks do much for the info. I'm going to go check out zoho.com right now.

Activity icon

Replied to Free Domain Emails

@SNAPEY - This looks pretty useful. So Mail in a box is free, but needs to run on it's own server / droplet which makes it $5 a month. Is that correct?

Jan
25
8 months ago
Activity icon

Replied to Free Domain Emails

I actually just finished setting up my Mailgun account for sending emails out. Had no idea I could use it to receive emails too. Will definitely try it out. Thanks for the tip!

Though what I'm looking for is a way to create a few free emails I can use for people on my team that I can IMAP to Outlook and my phone. Basically just like a regular "professional" domain email account.

I suppose I could create multiple email forwarders on GoDaddy and send to my gmail account... then Send emails from my gmail account using an email alias tied to my domain.

Was just hoping there was an easier solution than a hacky workaround.

Something similar to when Gmail used to let you create 5 free domain emails back in the day. Are there any other services like that today?

Activity icon

Started a new conversation Free Domain Emails

I came from using a shared hosting account for some of my small clients, but I've now moved on to using Vultr and Digital Ocean to host my websites. With shared hosting I was able to create multiple email account for each small business I managed via the cPanel. I could host over 20+ websites and have 5+ domain emails per site. Example: • [email protected][email protected][email protected] • etc...

Other than buying emails from Godaddy or creating domain emails via gmail's gSuite. Are there any options for creating personal domain emails via Vultr or Digital Oceans VPS. For free?

Jan
08
9 months ago
Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

Ah... I was adding it at the top of my script. Guess it totally makes sense to use it in my update function. Thanks so much. All is working now, and I have a better understanding on how this works. Appreciate your time! -Chris

Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

@vajid I'm at a lost here. If you could share anymore help I would greatly appreciate it.

Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

Can I see.. HAHA Okay let me try and fumble around with this and try and get it working.

So if I change to this on the lower half of the code...

$('#xyz').val((checkbox.checked ? f(goal) + f(charge) : f(goal)).toFixed(2));

I then need to change this on the top half...

var totalDonation = $('.total-box > span');
to
var $xyz = $(#xyz');

Does that sound correct?

Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

@cronix Since I need to use the value of the total amount multiple places wouldn't I use a class then? This should stay a class correct?

<h3 class="total-box" style="display: block;">
  Your total cost is $<span></span>
</h3>
    var totalBox = document.querySelector('.total-box');
    var totalDonation = $('.total-box > span');

@vajid why was this changed. Doing so breaks the rest of the code.

$('#xyz').val((checkbox.checked ? f(goal) + f(charge) : f(goal)).toFixed(2));

I understand I'm making this extremely more difficult than it needs to be, but I have fought my way up until this point, just need a little help so I can move on. In my codepen where I have START listed, should I move that down the page or leave it as is?

Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

@VAJID - Man, I'm not understanding what I'm doing wrong. This is what I'm using now.

<input type="hidden" id="xyz" name="xyz" value="">

Then..
var xyz = $('.total-box > span').eq(0).text();
console.log(xyz);
$('#xyz').val(xyz);

Still not getting anything in the hidden field value.?.?

Jan
07
9 months ago
Activity icon

Replied to How To Add A JS Variable Into A Hidden Form Value

@VAJID - I tried doing as you said, but it's still not adding the value to the field. You can test this in the codepen. https://codepen.io/daugaard47/pen/maxrBo?editors=1011

Activity icon

Started a new conversation How To Add A JS Variable Into A Hidden Form Value

I need to get the total amount of the radio button to pass into a hidden value so I can then pass it to stripe. I can get the total amount to render on the page, but I cannot seem to place it as a value in the hidden field.

This renders to the page.

HTML Snippet
<p class="total-box"><span></span></p>

JS Snippet
var totalDonation = $('.total-box > span');

And this is how I'm trying to place the hidden value:

var xyz = $('.total-box > span').text();
document.getElementById('xyz').value = xyz;

HTML Snippet:
<input type="hidden" id="xyz" name="xyz" value="">

Here is a [CodePen] to see the code and what I'm trying to do. (https://codepen.io/daugaard47/pen/maxrBo?editors=1011)