lawkunchi

lawkunchi

Member Since 11 Months Ago

Cape Town

Web Artisan at Empower Funding (Pty) Ltd.

Experience Points 3,540
Experience Level 1

1,460 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 3
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.

30 Apr
4 months ago

lawkunchi started a new conversation Integrating Other Payments Methods To Laravel Cashier

Can Laravel Cashier be integrated with other payment methods other than stripe

11 Mar
6 months ago

lawkunchi left a reply on Not Allow A User To Fill A Form Input Unless Previous Input Is Valid

@BRAUNSON - Yes that works, but I'm looking for something like a plugin as my form has a lot of inputs

lawkunchi started a new conversation Not Allow A User To Fill A Form Input Unless Previous Input Is Valid

Is there a way to not allow a user to fill a form input unless the previous input is filled and valid?

19 Feb
6 months ago

lawkunchi left a reply on Twilio For Whats App

@mvd found a solution. I wanted something that sends messages every hour, not an hour from time of creation.

I used laravel cron jobs which have a lot of methods to play with


//pending products command

public function handle() {

        if (Product::where('status', 0)->count() > 0) {
            $sid    = env('SID'); 
            $token  = env('AUTH_TOKEN'); 
            $twilio = new Client($sid, $token);
            $message = $twilio->messages 
                  ->create("whatsapp:+55 555 555", // to 
                           array( 
                               "from" => "whatsapp:+1 555 5555",       
                               "body" => "Hello, you have pending products" 
                           ) 
                  ); 
        print($message->sid);
            }
        }

//Kernel.php -for scheduling commands
protected function schedule(Schedule $schedule) {
        $schedule->command('pending:products')
                 ->hourly();
    }

lawkunchi left a reply on Redirect To The Desired Page When Authenicated

Thank you guys I got it

return redirect()->intended('default-page');
18 Feb
6 months ago

lawkunchi started a new conversation Redirect To The Desired Page When Authenicated

When someone tries to visit a page which requires authentication is redirected to a login page. How do I redirect them to their desired page after successful login rather than default link.

lawkunchi started a new conversation Twilio For Whats App

I'm using twilio to send messages to what's app I tested it and it's working. I need help for the message to be send every 1hr if the database table of products have products with status 0.

For instance example if there is products with status 0, a message is sent and if they are still products with status 0 after 1hr message is sent until they aren't products.

Thank you

//Controller

 public function pendingNotification() {
        $products   = Product::where('status', 0)->get();

        if ($products->any()) {
            $sid    = env('SID'); 
            $token  = env('AUTH_TOKEN'); 
            $twilio = new Client($sid, $token);
            $message = $twilio->messages 
                  ->create("whatsapp:+55 555 555", // to 
                           array( 
                               "from" => "whatsapp:+1 555 5555",       
                               "body" => "Hello, you have pending products" 
                           ) 
                  ); 
        print($message->sid);
        }
    }

lawkunchi started a new conversation Mistake

Twilio for sending message notifications

07 Feb
7 months ago

lawkunchi started a new conversation Laravel Escrow API

I'm creating a multi vendor online store. Basically a user buys and a seller delivers the goods. So I want a system where the funds are hold until the buyer confirms goods have been received, then funds are released to the seller. Does anyone know an Escrow API that I can use which is convenient or an easier way to do this.

Thank you!

30 Jan
7 months ago

lawkunchi started a new conversation Downloading Multiple Files As A Zip Using Chumper/Zipper

I'm trying to download multiple files stored in storage folder as a zip using chumper/zipper

I get this error

glob(): Pattern exceeds the maximum allowed length of 2048 characters

My Controller

public function downloadZip($id) {

        $user = User::findorFail($id);

        $zipper = new \Chumper\Zipper\Zipper;
        $images = Storage::get($user->images);
        $files = glob($images);
        $zipper->make(public_path('users/images.zip'))->add($files);
        $zipper->make(public_path('users/images.zip'))->extractTo(public_path('users'));
        $zipper->close();
        return response()->download(public_path('users/images.zip'));
    }
16 Jan
7 months ago

lawkunchi started a new conversation Mistake

Mistake

10 Jan
8 months ago

lawkunchi left a reply on How To Get Monthly Users Month By Month For A Table

@DIGITALIZED - Thanks I'm trying to add this data to a graph also using chartist js.But the data is not tallying as below

Capture

My View

var chart = new Chartist.Line('.ct-chart1', {
  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], //registered month
  series: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] //number of users

//What I used to get number of users
series: [
    @foreach($users as $user => $created_at)
        [ "{{ $user}}"], 
    @endforeach

    ]
},

09 Jan
8 months ago

lawkunchi left a reply on How To Get Monthly Users Month By Month For A Table

@DIGITALIZED - Thanks this worked, but I'm getting the month in the format of numbers

lawkunchi left a reply on How To Get Monthly Users Month By Month For A Table

I'm looking to make something like this, but all I get is total number of users

@digitalized @Shawdow @RoboRobok

Capture

lawkunchi left a reply on How To Get Monthly Users Month By Month For A Table

@ROBOROBOK - My users table dosen't have a column of month, date is stored in column created_at from timestamps.

lawkunchi started a new conversation How To Get Monthly Users Month By Month For A Table

I have a table which tally number of users against the month they were created. So I'm stuck on how to get number of users for each month.

<table>
        <thead>
            <tr>
                <th>Jan</th>
                <th>Feb</th>
                <th>March</th>
                <th>Apr</th>
                <th>May</th>
            </tr>
        </thead>
        <tbody>

            @foreach($users as $user)
            <tr>
                <td>{{ $user->created_at->format('M')->count}}</td> //Stuck here
            </tr>
           @endforeach

        </tbody>
 </table>

lawkunchi started a new conversation Laravel Graph Using Chartist JS

I'm using Chartist JS to create a graph for number of registered users against the registered month. Below is my code so far. I'm getting repeated months and it's not tallying with the number of users. So I need help. Thanks

Javascript

var chart = new Chartist.Line('.ct-chart1', {
  labels: [
      @foreach ($users as $user)
        [ "{{ $user->created_at->format('M') }}"], 
      @endforeach  
  ],
  series: [
   @foreach ($users as $user)
        [ "{{ $user->count() }}"], 
    @endforeach
  ]
}, {
  low: 0,
  showLine: false,
});
Controller

 public function getChart()
    {
        $users = User::All()->where('type', 'default');
        return view('users.chart')->with('users', $users);
    }
07 Jan
8 months ago

lawkunchi started a new conversation Date/Age Validation

What is the best way to validate date input, so that the age is over 18 years from the current date using JavaScript?

14 Dec
9 months ago

lawkunchi started a new conversation Google Map Api

I'm using google map api to auto populate an address. So I have a form which requires 2 different addresses, so how do I go about auto populating the next address like the form below.


THE FORM
      <form>
        <ul>
          <li class="li">
            <label>Enter Address</label>
            <input type="text" id="autocomplete" name="address">
          </li>

          <li class="li">
            <label>Street Address</label>
            <input type="text"  id="street_number">
          </li>

          <li class="li">
            <label>City</label>
            <input type="text" class="field" id="locality">
          </li>

          <li class="li">
            <label>State</label>
            <input type="text" id="administrative_area_level_1">
          </li>

          <li class="li">
            <label>Zip Code</label>
            <input type="number" id="postal_code">
          </li>
          <li>
            <label>Country</label>
            <input type="text" id="country">
          </li>
        </ul>


        <ul>
          <li class="li">
            <label>Enter Address</label>
            <input type="text" id="autocomplete" name="address">
          </li>

          <li class="li">
            <label>Street Address</label>
            <input type="text"  id="street_number">
          </li>

          <li class="li">
            <label>City</label>
            <input type="text" class="field" id="locality">
          </li>

          <li class="li">
            <label>State</label>
            <input type="text" id="administrative_area_level_1">
          </li>

          <li class="li">
            <label>Zip Code</label>
            <input type="number" id="postal_code">
          </li>
          <li>
            <label>Country</label>
            <input type="text" id="country">
          </li>
        </ul>

      </form>
THE JS FROM GOOGLE

var placeSearch, autocomplete;
      var componentForm = {
        street_number: 'short_name',
        route: 'long_name',
        locality: 'long_name',
        administrative_area_level_1: 'short_name',
        country: 'long_name',
        postal_code: 'short_name'
      };

      function initAutocomplete() {
        // Create the autocomplete object, restricting the search to geographical
        // location types.
        autocomplete = new google.maps.places.Autocomplete(
            /** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
            {types: ['geocode']});

        // When the user selects an address from the dropdown, populate the address
        // fields in the form.
        autocomplete.addListener('place_changed', fillInAddress);
      }

      function fillInAddress() {
        // Get the place details from the autocomplete object.
        var place = autocomplete.getPlace();

        for (var component in componentForm) {
          document.getElementById(component).value = '';
          document.getElementById(component).disabled = false;
        }

        // Get each component of the address from the place details
        // and fill the corresponding field on the form.
        for (var i = 0; i < place.address_components.length; i++) {
          var addressType = place.address_components[i].types[0];
          if (componentForm[addressType]) {
            var val = place.address_components[i][componentForm[addressType]];
            document.getElementById(addressType).value = val;
          }
        }
      }

      // Bias the autocomplete object to the user's geographical location,
      // as supplied by the browser's 'navigator.geolocation' object.
      function geolocate() {
        if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var geolocation = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
            };
            var circle = new google.maps.Circle({
              center: geolocation,
              radius: position.coords.accuracy
            });
            autocomplete.setBounds(circle.getBounds());
          });
        }
      }

13 Dec
9 months ago

lawkunchi started a new conversation Laravel Notifications

I used laravel notifications to send emails. It was working, suddenly emails are not being received.

So does anyone know what causes the delay of notifications or otherwise? Thanks

lawkunchi left a reply on Get Download Link Of A File In Laravel 5.7

I wanted to download a file uploaded by user and it was saved in the user's table. Below is my final code. Thank you!

 public function download($id) {
        $user = User::findorFail($id);
        return Storage::download($user->file);
    }
Route::get('download/{id}', [
            'uses' => '[email protected]',
            'as' => 'file.download'
        ]);
06 Dec
9 months ago

lawkunchi left a reply on Get Download Link Of A File In Laravel 5.7

My files are being stored in the Storage folder. When I use this method .

I get this error 'Sorry, the page you are looking for could not be found.

lawkunchi started a new conversation Get Download Link Of A File In Laravel 5.7

How to generate a download link of a file uploaded by a user.

30 Nov
9 months ago

lawkunchi left a reply on Laravel Session

@SERGIU17 - Thank you for the tip, my final code below and it works perfectly

My View
<script>
 $(document).ready(function(){
        var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
        $('.back-button').click(function() {
            $.ajax({
                url: 'cancel',
                type: 'GET',
                data: {_token: CSRF_TOKEN, message:$("#email").val()},
                dtatType: 'JSON',
             
               success: function(data) {
                   $('message').append(data.msg);
                }
            });
        });
    });
</script>
Route::get('cancel', [
            'uses' => '[email protected]',
            'as' => 'cancel',
        ]);

My Controller

public function cancelButton(Request $request) {
        $response = array(
            'status' => 'failed',
            'msg' => $request->message,
        );
        $user = Auth::user();
        Event::fire(new EventName($user));

        \Mail::to('[email protected]')->send(new MailName($user));
        return response()->json($response);
    }
28 Nov
9 months ago

lawkunchi left a reply on Laravel Session

@SERGIU17 - By closing the window tab or going back to the previous page

lawkunchi started a new conversation Laravel Session

Is there a way to get authenticated user information send to admin's email when they try for example to create a post but decided to quit.

20 Nov
9 months ago

lawkunchi started a new conversation Mark Down Table

Is there a way to increase the size of a column width using laravel markdown table. Things are coming out pretty weird.

lawkunchi left a reply on Admin Model

@aurawindsurfing

\Mail::to('[email protected]')->send(new Welcome($user));
I used Notifications to send email to users after registering

public function sendVerificationEmail() {

        $this->notify(new VerifyEmail($this));
    }

I wanted to send email to admin different from the user's email with user's data, that's why I had used the code above, not to send email to the user. Finally This Worked for me. Thank you!

lawkunchi started a new conversation Admin Model

I would like to send an email to admin when a new user register, but I'm having an issue of accessing the Admin Model in the controller. Thank you

use App\Admin;

$admin = ?
\Mail::to($admin, $user)->send(new NewUser($admin, $user));
19 Nov
9 months ago

lawkunchi started a new conversation Mail Error

I'm trying to send emial to the user and admin after the user registers.

But I got this error
Class 'App\Http\Controllers\NewUser' not found

Anyone with idea how I can solve this, New mail was created and I'm using it in the contorller as well

In the Controller
\Mail::to($user)->send(new Welcome($user));
\Mail::to($admin)->send(new NewUser($admin));
16 Nov
9 months ago

lawkunchi left a reply on Laravel PDF

@romulo27 So this package allows you to convert a page into a pdf file so you can create a view for the pdf file which you can render data there, so I want to style the pdf file but the css is not being loaded. You can find more info about the package here laravel-dompdf

Below is the controller that convert a page into pdf

 public function downloadPDF($id) {
        $deal = Deal::find($id);

        $pdf = PDF::loadView('account.pdf', compact('deal'));
        return $pdf->download('contract.pdf');
    }

lawkunchi started a new conversation Laravel PDF

I'm using this package to generate pdf file barryvdh but had issue with loading bootstrap css. Anyone know an alternative or how I can load bootstrap css

15 Nov
10 months ago

lawkunchi left a reply on Install/Upload Packages On A Live Server

@aurawindsurfing Cause I had uploaded the project already and needed to make some changes which requires installing a new package. So I thought there would be an easier approach.

lawkunchi started a new conversation Install/Upload Packages On A Live Server

Is there a way to install packages or upload them on a live server through cpanel. Thanks

lawkunchi left a reply on Laravel Mail

@aurawindsurfing I got it thanks!!

lawkunchi started a new conversation Laravel Mail

I have a form where user enter details. I want to sent details from the form to their email. I get this error undefined variable deal, if I remove the the variable it works fine. So the question is how do I define this variable so I could send the email to user with data from the form. Thanks

After they fill the form they get sent the blade below

Mail Blade
<div>
Here is the info you provided us below
      <li>{{ $deal->property_address }}</li>
</div>
My Controller

 public function postDeal(Request $request)  {
        $this->validate($request, [
                'property_address' => 'string|required|max:100',
        ]);
       $deal = new Deal([
                'property_address' => $request->input('property_address'),
        ]);
      $deal->save();
    }
$user = Auth::user();
 \Mail::to($user)->send(new NewDeal($user));
Mail

     public $user;

    public function __construct(User $user) {
        $this->user = $user;
    }

    public function build()
    {
        return $this->view('emails.new-deal');
    }
14 Nov
10 months ago

lawkunchi left a reply on Multiple File Upload

@sergiu17 Yes it can't

lawkunchi started a new conversation Multiple File Upload

How do I store file paths of multiple file upload input. Below is my controller so far

public function postDeal(Request $request) 
    {
        $this->validate($request, [

            'property_address' => 'string|required|max:100',
            'sell_price' => 'string|required|max:100',
            'docs' => 'required|max:10000',
        ]);

        $files  = $request->file('docs');
        $paths = [];

        foreach( $files as $file) {
            $extension = $file->getClientOriginalExtension();
            $filename = 'sup-doc-' . time() . '.' . $extension;
            $paths[] = $file->storeAs('Deals', $filename);
        }

        $deal = new Deal([
            'property_address' => $request->input('property_address'),
            'sell_price' => $request->input('sell_price'),
            'docs' => $paths,
        ]);
        $deal->save();
    }
13 Nov
10 months ago

lawkunchi started a new conversation File Upload Error (Call To A Member Function Store() On Null)

I used the same code form Laravel Documentation in my other controller it worked fine and now it's not working in another form. Anyone with idea why I get the above error. Thanks

My Controller

public function postDeal(Request $request) 
    {
        $this->validate($request, [
            'file' => 'required|max:2048',
        ]);

        $path = $request->file('file')->store('Uploads');

        $deal = new Deal([
            'file' => $path,
        ]);

        $deal->save();
    }
My Form
form action="{{ route('deal.request')}}" method="POST" enctype="multipart/form-data">
       @csrf
      <input type="file" name="file" id="file">
     <button type="submit">Submit Request</button>
 </form>

lawkunchi started a new conversation Send Email To Admin When A New User Registers

I want to send an email to admin when a new user registers. What I have below can successfully send email to the user who just registered, So I want to know how I will go about sending to admin as well when a new user registers.

User Controller
public function postRegister(Request $request) 
    {

        $this->validate($request, [
            'first_name' => 'string|required|max:100',
            'last_name' => 'string|required|max:100',
            'email' => 'email|required',
            'password' => 'string|required',

        ]);

        $user = new User([
            'first_name' => $request->input('first_name'),
            'last_name' => $request->input('last_name'),
            'email' => $request->input('email'),
            'password' => bcrypt($request->input('password')),
        ]);

        \Mail::to($user)->send(new Welcome($user));


        return redirect('account/login')->with('status', 'Thanks for signing up! Please check your email.');
    }

Welcome Email

class Welcome extends Mailable
{

    use Queueable, SerializesModels;

     public $user;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(User $user) {
        $this->user = $user;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.welcome');
    }
}
09 Nov
10 months ago

lawkunchi left a reply on User Verification

@munazzil if i do it that way the token won't get sent just any empty verification link

supposed to be like this account/user/verify/generated -token

instead i get account/user/verify/

lawkunchi left a reply on User Verification

it's not that the error is here

<a href="{{ route('user.verify', $user->verifyUser->token) }}">verify account</a>

Because when I remove this it works perfectly fine Below is the full code of the mail

namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Welcome extends Mailable
{
    use Queueable, SerializesModels;
     public $user;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(User $user) {
        $this->user = $user;
    }
    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.welcome');
    }
}

lawkunchi left a reply on User Verification

@mushood Yes User data and verifcation data gets saved as well

This is the function that returns the view

  public function build()
    {
        return $this->view('emails.welcome');
    }

The view

<body>

    <main >Hello, {{ $user->first_name }} {{ $user->last_name }}</h4>

    <p >Click link below to activate the account</p>

    <a href="{{ route('user.verify', $user->verifyUser->token) }}">VERIFY MY ACCOUNT</a>

    <h1>Thank You!</h1>

</body>

lawkunchi left a reply on User Verification

@munazzil Yeah the model name is Verify User. But I do not want to display the output I want to send it to the user when they register

lawkunchi started a new conversation Laravel Sesions

I have a form where a user post data, I created a token for every form created in order to approve it. So the token gets send to admin and the form contents and approve token url.

So a user has a table in the account with posted form data and a one of the column is a Status where admin has approved it or not. So in my controller I have a status variable which I want to be in my view. I used if statements but it shows similar status in the column for all rows.

The questions is how can I get session status that corresponds to each row.

Controller to approve

 public function approveDeal($token) {
        $approveDeal  = ApproveDeal::where('token', $token)->first();
        if(isset($approveDeal) ) {
            $deal = $approveDeal->deal;
            if(!$deal->approved) {
                $approveDeal->deal->approved = 1;
                $approveDeal->deal->save();
                $status = "Approved";
            }else {
                return redirect('account/deals')->with('status', "pending");
            }
        }else {
            return redirect('account/deals')->with('warning', "Denied");
        }

        return redirect('account/deals')->with('status', $status);
    }
The view
                        <td>
                            @if (session('status'))
                            <small class="alert alert-success" style="">
                                {{ session('status') }}
                            </small>
                            @endif

                            @if (session('warning'))
                            <small class="alert alert-danger" style="">
                                {{ session('status') }}
                            </small>
                            @endif
                        </td>

lawkunchi left a reply on User Verification

@munazzil I've a group route with prefix account just pasted the specific route

lawkunchi left a reply on User Verification

@d9705996 thanks I will check it out

lawkunchi left a reply on User Verification

@munazzil Displaying routes here it comes out clumsy

GET|HEAD | account/user/verify/{token} | user.verify      | App\Http\Controllers\[email protected]         | web,guest 

lawkunchi left a reply on User Verification

@mushood Full error message

ErrorException (E_ERROR)
Trying to get property of non-object (View: /home/empowcnk/public_html/accounts/resources/views/emails/welcome.blade.php)
08 Nov
10 months ago

lawkunchi left a reply on User Verification

@mushood Tried, still same error thanks anyway