daugaard47

daugaard47

Member Since 1 Year Ago

Experience Points 11,880
Experience Level 3

3,120 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 106
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.

08 Aug
1 week ago

daugaard47 left a reply on 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?

daugaard47 left a reply on 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" ] 
]

daugaard47 left a reply on 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.

daugaard47 left a reply on 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

daugaard47 left a reply on 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,
            ...
        ]);

daugaard47 left a reply on 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"}]

daugaard47 left a reply on 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

daugaard47 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.

24 Apr
3 months ago

daugaard47 left a reply on Radial Progress Bar

Still would like to know how Jeffery does it though.

daugaard47 left a reply on 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;
    }
  };
})();
23 Apr
3 months ago

daugaard47 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.

19 Apr
4 months ago

daugaard47 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.

24 Mar
4 months ago

daugaard47 left a reply on 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.

12 Mar
5 months ago

daugaard47 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
19 Feb
6 months ago

daugaard47 left a reply on 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.

daugaard47 left a reply on 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

18 Feb
6 months ago

daugaard47 left a reply on 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.

daugaard47 left a reply on 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.

daugaard47 left a reply on 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.
15 Feb
6 months ago

daugaard47 left a reply on 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.

daugaard47 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!

11 Feb
6 months ago

daugaard47 left a reply on Combined First And Last Name

@CRONIX - Nice solution! Appreciate the help.

daugaard47 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}}
06 Feb
6 months ago

daugaard47 left a reply on 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!

daugaard47 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!

26 Jan
6 months ago

daugaard47 left a reply on Free Domain Emails

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

daugaard47 left a reply on 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?

25 Jan
6 months ago

daugaard47 left a reply on 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?

daugaard47 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?

08 Jan
7 months ago

daugaard47 left a reply on 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

daugaard47 left a reply on 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.

daugaard47 left a reply on 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?

daugaard47 left a reply on 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?

daugaard47 left a reply on 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.?.?

07 Jan
7 months ago

daugaard47 left a reply on 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

daugaard47 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)

19 Jun
1 year ago

daugaard47 left a reply on Using Instafeed.js With Laravel 5

@ygordreyer is correct. This worked like a charm.

10 Apr
1 year ago

daugaard47 started a new conversation Redirect To Login Page After Session Expires

Can someone please help explain what I need to do to redirect back to the login page once the session expires? I cannot seem to figure this out for the life of me.

I've tried doing the following, but it only works when I physically press the logout button.

App/Http/Controllers/LoginController

namespace App\Http\Controllers\Auth;

use Auth;
use Illuminate\Http\Request;
use App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

public function logout(Request $request)
{
    $this->guard()->logout();

    $request->session()->flush();

    $request->session()->regenerate();


    return redirect('/login')->with('info','You have been logged out.');
}

}
06 Apr
1 year ago

daugaard47 left a reply on Image Processing In Intervention Unisharp File Manager

png to jpg is working for me by doing the following:

            Image::make($maintenanceImg)->insert(public_path().'/images/watermark.png', 'bottom-right', 50, 50)->encode('jpg', 65)->resize(760, null, function ($c) {
                $c->aspectRatio();
                $c->upsize();
                })->save(public_path('/images/users/'.Auth::user()->username.'/tickets/' . $filename));

I realize that it's the same code as you, but I check the mime type of the png to make sure it was a true png before uploading:

Link: http://forum.sources.ru/mime.php

I checked it after and it was a jpg and the mime checked out too.

Original png: Imgur

Encoded jpg (FYI, the watermark is white, so it's hard to see): Imgur

Here is one showing the watermark: Imgur

Here is the full event service provider:

namespace App\Providers;

use Unisharp\Laravelfilemanager\Events\ImageWasResized;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

use Unisharp\Laravelfilemanager\Events\ImageWasUploaded;
use App\Listeners\HasUploadedImageListener;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\NewUser' => [
            'App\Listeners\SendWelcomeEmail',
            'App\Listeners\SendNewUserCreated',
        ],

            'App\Events\Event' => [
            'App\Listeners\EventListener',
        ],

        ImageWasUploaded::class => [
            HasUploadedImageListener::class
        ],


    ];
30 Mar
1 year ago

daugaard47 left a reply on Paginate Issue Laravel 5.6

Not sure why that's not working. I'm using ->paginate() on another view and everything works as normal.

In this case this ended up working: {{ $news->links() }}.

I did try {{ $news->paginate() }}, but threw an error.

I ended up using this query:

$news = DB::table('news')->orderBy('id', 'DESC')->paginate(4);

@burlresearch Thanks for taking time to help.

29 Mar
1 year ago

daugaard47 started a new conversation Paginate Issue Laravel 5.6

Was wondering if someone could check this out and let me know what I'm doing wrong. I'm trying to use paginate on a database query and render it in my view. Here is what I'm working with.

Controller:

            public function index()
    {
       // $news = DB::table('news')->orderBy('id', 'DESC')->paginate(4);
        $news = DB::table('news')->select('id','title','description','listing_image','created_at','updated_at')->orderBy('id', 'DESC')->paginate(4);
        return view('news.index',compact('news'));
    }

View: (Getting error: Call to undefined method stdClass::paginate() )

@if ($news->count())
@foreach($news as $item)
...html
 @if ($item->listing_image)
...more html

    @else
    @endif 

... more html

@endforeach

{{$item->paginate(4)}} 
@endif 

Is something wrong with this? {{$item->paginate(4)}} Should mention that everything renders fine if I remove paginate from the query in the controller.

18 Mar
1 year ago

daugaard47 left a reply on Package Issue (spatie/laravel-image-optimizer)

If your good with using jpg images, why not simply ditch the spatie package and optimize your image with Intervention Image?

Image::make($theImage)->encode('jpg', 65)->resize(1560, 1160, function ($constraint)... etc

http://image.intervention.io/api/encode

I usually resize all my images to 760px wide, then use css cover or set the width to 100% with min-width & and max-width values to fit my needs.

Image::make($theImage)->encode('jpg', 65)->resize(760, null, function ($c)...

Encoding Breakdown:

  1. Converting all images to a .jpg
  2. 65 is the jpg image quality. (Similar to the save for web function in Photoshop)
  3. Resizing to 760px wide and keeping the aspect ratio

Note Intervention Image will not compress/optimize png images though.

Hope this helps.

daugaard47 left a reply on E-commerce In Laravel

I was reviewing this in depth awhile back and found a few great courses on YouTube:

Course 1 Playlist:

Course 2 Playlist:

Course 3 Playlist:

Note that none of these video courses cover one of the most important parts which is shipping. Though you can use this 3rd party service to help with that:

If your only selling a couple products, you could do it all through Stripe. Here are the docs for creating products and flat-rate shipping:

By far the easiest way to go would be Shopify. For small sites, sign up for the $9 a month Shopify Lite Plan and use the Buy button to place products on your website.

If you need the Basic Shopify plan there is a couple laravel wrappers available:

Hope this helps you. Please let us know what you decide to go with.

17 Mar
1 year ago

daugaard47 left a reply on Query - Left Join - Expire Post After 30 Days

@Sanctuary Thank you for the help and the detailed explanation . That worked great, much appreciated!

16 Mar
1 year ago

daugaard47 started a new conversation Query - Left Join - Expire Post After 30 Days

Pretty new to Laravel and I'm trying to update the code of an old project to Laravel. My question is how should I go about writing a LEFT JOIN query? In this example I will use a classifieds page. I understand how to show my classified listings from the database. I would write my classified controller like so:

    public function index()
    {
        $classifieds=Classified::all();
        return view('classifieds.index',compact('classifieds'));
    }

Then in my view call the database like this:

@foreach($classifieds as $cls)
Call Title{{$cls->title}}
Call Description{{$cls->description}}
Call Image<img src="{{$cls->listing_image}}">
ETC...
@endforeach 

In this case I'm having issues with a LEFT JOIN query. I'm wanting the classified listing to expire after 30 days.

This is my old working code, but how would I rewrite this in Laravel? And would I put this in my controller? How can I use it to extend the above public function? Query Code:

$classifieds = DB::getInstance()->query("SELECT users.id, users.first_name, users.last_name,  users.avatar,
classifieds.title, classifieds.dates, classifieds.file_name, classifieds.description
FROM users LEFT JOIN classifieds ON users.id = classifieds.user_id
WHERE classifieds.dates > DATE_SUB(NOW(), INTERVAL 43200 MINUTE) AND classifieds.user_id=$userid");

Any help would be greatly appreciated. Thank you!

07 Mar
1 year ago

daugaard47 started a new conversation For Hire: Add Stripe Transaction Fees To Variable Amount Entered

I have a very small project I’m trying to complete, but stuck on a JS section. Willing to pay by PayPal. (Normally I would try and figure it out, but don't have the time at the moment and need to move forward with the project.)

It’s for a donation system. I need to give the donor the ability to GIFT the Stripe / PayPal transaction fees so the non-profit gets 100% of the donation.

I have the fees formula pieced together, but need help adding the fees to the total amount / variable amount being donated.

Here is the JSFiddle Please review. All is explained in the Fiddle.

Here is the code, so you can see what you're working with.

HTML:

<div class="input-field-container">
  <span>$</span>
  <input type="number" min="1.00" max="200000.00" step="0.01" value="60" id="other_amount" name="other_amount" class="p-goal">
  <span>USD</span>
</div>



  <input type="hidden" id="f-fixed" type="number" value="0.30">

  <input type="hidden" id="f-percent" type="number" value="2.9">

 
<p>Would you like to gift the transaction fee $<input size='5' id="p-charge" type="number" disabled>
  <br>so we can recieve 100% of your donation?
  <br>
  <input type="checkbox" value="yes" name="yes" /> Check box for yes
</p>

JS:

var Pgoal = document.querySelector('.p-goal');
var Ffixed = document.querySelector('#f-fixed');
var Fpercent = document.querySelector('#f-percent');
var Pcharge = document.querySelector('#p-charge');

function f(n) {
  return Number((+n).toFixed(10));
}

function calcPcharge(goal, fixed, percent) {
  return (goal + fixed) / (1 - percent);
}

function update() {
  var charge = calcPcharge(f(Pgoal.value), f(Ffixed.value), f(Fpercent.value / 100));
  Pcharge.value = (charge || 0).toFixed(2);
}

[].forEach.call(document.querySelectorAll('input'), function() {
  this.addEventListener('input', update);
});

06 Mar
1 year ago

daugaard47 left a reply on Check For Image Then Delete

@Sergiu17 @biishmar Thank you both for the help. It kept skipping over my IF statement when the post didn't have an image and would error on the unlink function.

I realized that I had my images set to NULL be default in the database. So if($pic == NULL){ did the trick along with the file_exists.

Thanks again.

Here is the full code block if it might help someone else:

public function destroy(Request $request, $classifiedId)
{
        $cfImg = DB::select("SELECT `listing_image` FROM `classifieds` WHERE ID = $classifiedId");
            foreach($cfImg as $listing_image){
                $pic =  ($listing_image->listing_image);
            }

if($pic == NULL){
            
            Classified::destroy($classifiedId);
            return redirect()->route('classifieds')->with('deleted','Your listing has been deleted.');
        }
            if(file_exists(public_path().'/images/users/classifieds/'.$pic)){
                unlink(public_path().'/images/users/classifieds/'.$pic);
                Classified::destroy($classifiedId);
                return redirect()->route('classifieds')->with('deleted','Your listing has been deleted.');
        }
    }
}

daugaard47 left a reply on Check For Image Then Delete

@biishmar Thanks for the help.

I'm getting an error, "Trying to get property of non-object" on $pic = $cfImg->listing_image; ..?

daugaard47 started a new conversation Check For Image Then Delete

I'm trying to check for if an image is in my database. I used the if($request->hasFile('listing_image')) but doesn't seem to be working.

So I changed my IF statement to this:

public function destroy(Request $request, $classifiedId)
{
        $cfImg = DB::select("SELECT `listing_image` FROM `classifieds` WHERE ID = $classifiedId");
        if (('listing_image') == true){
            foreach($cfImg as $listing_image){

                $pic =  ($listing_image->listing_image);
            }

            unlink(public_path().'/images/users/classifieds/'.$pic);
            Classified::destroy($classifiedId);
        }else{

            Classified::destroy($classifiedId);
        }

        return redirect()->route('classifieds')->with('deleted','Your listing has been deleted.');
    }
     
}

This will delete the post and remove the image from my folder, but if the post doesn't have a image it's still trying to unlink the file, causing and error.

What I want to do:

If post has image, delete post and remove image from folder

Else ... if post does not have an image, just delete the post.

Pretty new to laravel, what would be the correct IF statement here?