lawkunchi

lawkunchi

Web Artisan at Empower Funding (Pty) Ltd.

Cape Town

Member Since 2 Months Ago

Experience Points 2,920
Experience
Level
Lessons Completed 3
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

14 Dec
3 days 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 to different days, 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
4 days 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
1 week 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
2 weeks ago

lawkunchi left a reply on Laravel Session

@SERGIU17 - Thanks man for the tip, main final files of my code below and it works perfectly

My View
 $(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);
                }
            });
        });
    });
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($user)->send(new MailName($user));
    return response()->json($response);
}
28 Nov
2 weeks 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
3 weeks 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

@au

\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
4 weeks 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
1 month ago

lawkunchi left a reply on Laravel PDF

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 to be allow download of the pdf file being converted

 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
1 month 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

$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
1 month 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
1 month ago

lawkunchi started a new conversation File Uplaod 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 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 I Want To Send An Admin When User Register

I want to send an email to a Admin when a new user register. 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.

public function postRegister(Request $request) 
User Controller
    {

        $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
1 month 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 verified flag is correctly updated in for the user

This is the function that send's the email

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

The view

<body>

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

    <p >To activate your acount, we need to know you received this Email. <br>
        Please click on the button below to confirm that.
    </p>

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

        <h1>Thank You!</h1>
    </footer>
    </main>

</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 Larvel 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('warning', "Denied");
            }
        }else {
            return redirect('account/deals')->with('warning', "pending");
        }

        return redirect('account/deals')->with('status', $status);
    }
The view
                        <td>{{ $deal->approved}}
                            @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 Dissplaying 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

+--------+----------+-----------------------------+------------------+--------------------------------------------------------+--------------+
|        | GET|HEAD | /                           |                  | Closure                                                | web          |
|        | GET|HEAD | account/dashboard           | dashboard        | App\Http\Controllers\[email protected]       | web,auth     |
|        | POST     | account/login               | login            | App\Http\Controllers\[email protected]          | web,guest    |
|        | GET|HEAD | account/login               | login            | App\Http\Controllers\[email protected]           | web,guest    |
|        | GET|HEAD | account/logout              | logout           | App\Http\Controllers\[email protected]          | web,auth     |
|        | GET|HEAD | account/profile             | profile          | App\Http\Controllers\[email protected]         | web,auth     |
|        | POST     | account/register            | register         | App\Http\Controllers\[email protected]       | web,guest    |
|        | GET|HEAD | account/register            | register         | App\Http\Controllers\[email protected]        | web,guest    |
|        | GET|HEAD | account/requestfinance      | requestfinance   | App\Http\Controllers\[email protected]  | web,auth     |
|        | GET|HEAD | account/user/verify/{token} | user.verify      | App\Http\Controllers\[email protected]         | web,guest    |
|        | PATCH    | account/user/{user}/profile | profile.update   | App\Http\Controllers\[email protected]             | web,auth     |
|        | GET|HEAD | admin/dashboard             | admin.dashboard  | App\Http\Controllers\[email protected]             | web,auth     |
|        | GET|HEAD | admin/deals                 | admin.deals      | App\Http\Controllers\[email protected]          | web          |
|        | GET|HEAD | api/user                    |                  | Closure                                                | api,auth:api |
|        | GET|HEAD | signature                   | signature        | App\Http\Controllers\[email protected]  | web          |
|        | POST     | signature                   | signature.save   | App\Http\Controllers\[email protected] | web          |
+--------+----------+-----------------------------+------------------+--------------------------------------------------------+--------------+

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
1 month ago

lawkunchi left a reply on User Verification

@mushood Tried, still same error thanks anyway

lawkunchi left a reply on User Verification

Database Structure

    public function up()
    {
        Schema::create('verify_users', function (Blueprint $table) {
            $table->integer('user_id');
            $table->string('token');
            $table->timestamps();
        });
    }

lawkunchi started a new conversation User Verification

I have a user controller which send email to user when they register it works perfectly fine, but when included a verification token in the email I got an error. I was developing it on a localhost and the verifcation token it was working using mailtrap.io but on a live server it's not working.

User verification code below inside User Controller

 public function verifyUser($token) {
        $verifyUser  = VerifyUser::where('token', $token)->first();
        if(isset($verifyUser) ) {
            $user = $verifyUser->user;
            if(!$user->verified) {
                $verifyUser->user->verified = 1;
                $verifyUser->user->save();
                $status = "Your e-mail is verifeid. You can now login to continue";
            }else {
                $status = "Your e-mail is already verified. You can now login to continue!";
            }
        }else {
            return redirect('account/login')->with('warning', "Sorry your email cannot be identified");
        }

        return redirect('account/login')->with('status', $status);
    }
Link send to email to verify email
<a href="{{ route('user.verify', $user->verifyUser->token) }}">verify account</a>

Route

Route::get('/user/verify/{token}', [
            'uses' => '[email protected]',
            'as' => 'user.verify'
        ]);

02 Nov
1 month ago

lawkunchi started a new conversation File Validation

I have form that requires a file. When a try to post this form I get this error "The id doc must be a file of type: jpeg, png, jpg, doc, docx, pdf."

Yet I uploaded the correct file. Don't tell me I should read the manual if you can't help, keep it to yourself!!


My controller

 public function postDeal(Request $request) 
    {

        If(Input::hasFile('id_doc')){
            $file = Input::file('id_doc');
            $destinationPath = public_path(). '/images/uploads';
            $filename = $file->getClientOriginalName();
            $doc= time().$filename;
            $file->move($destinationPath, $doc);
            $filePath = 'public/images/uploads'.$doc;
        }

        $this->validate($request, [
            'title' => 'string|required|max:100',
            'first_name' => 'string|required|max:100',
            'last_name' => 'string|required|max:100',
            'dob' => 'date|required',
            "id_doc" => 'required|mimes:jpeg,png,jpg,doc,docx,pdf|max:2048',
            'email' => 'email|required',
        ]);

        $deal = new Deal([
            'title' => $request->input('title'),
            'first_name' => $request->input('first_name'),
            'last_name' => $request->input('last_name'),
            'dob' => $request->input('dob'),
            'id_doc' => $filePath,
            'email' => $request->input('email'),
        ]);

        $deal->save();
        return redirect()->route('dashboard');
    }
31 Oct
1 month ago

lawkunchi left a reply on Signature Pad Update

@snapey The signature from the sketch is supposed to be saved as an image after being converted. And in the database I would save it's path.

30 Oct
1 month ago

lawkunchi left a reply on Signature Pad Update

supposed to be the path of the signature

29 Oct
1 month ago

lawkunchi started a new conversation Signature Pad Update

So I have been working around the signature pad and I seem to not pass this code error I'm getting.

The error I'm getting Undefined offset: 1
referring to this part  $encoded_image = explode(",", $data_uri)[1];

My Controller

    public function postSignature(Request $request) {

        $user = $request->session()->get('user');

        $signature = new Signature;
        $signature->user_id = $request->session()->get('user.id');
        $signature->position = $request->position;

        $data_uri = $request->signature_data;
        $encoded_image = explode(",", $data_uri)[1];
        $decoded_image = base64_decode($encoded_image);

        $sig = sha1($request->session()->get('user.first_name').$request->session()->get('user.last_name')) . "_signature.png";
        $folder = '/images/signatures/';

        Storage::put($folder, $sig);

        $signature->signature = $encoded_image;
        $signature->save();

        $request->session()->put('user', $user->load('account', 'signature'));
        return back();
    }

My Blade

  <form action="{{ route('signature.save') }}" method="POST" id="sign_form"> 
    @csrf
    <div id="signature-pad" class="signature-pad">

        <div class="digital-signature">
            <div class="form-group"><canvas id="signature-pad" class="signature-pad" width="7500" height="400"></canvas></div>
        </div>

        <div class="form-group">
            <input type="hidden" id="signature_data" name="signature_data" class="form-control" value="">
        </div>
        
    </div>

    <div class="signature-pad--footer">
      <div class="description">Sign above</div>

      <div class="signature-pad--actions">
        <div>
          <button type="button" class="button clear" data-action="clear" id="clear">Clear</button>

        </div>
        <div>
          <button type="submit" class="button save" data-action="save" id="save">Save</button>
          <input type="button" class="btn btn-default btn-sm" id="saveSign" value="Add Signature">
        </div>
      </div>
    </div>
  </div>
  </form>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/signature_pad.min.js"></script>
<script type="text/javascript" src="{{ URL('js/sign.js') }}"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

<script> 
$( function() {
    
    var signaturePad = new SignaturePad(document.getElementById("signature-pad"), {
          backgroundColor: 'rgba(255, 255, 255, 0)',
          penColor: 'rgb(0, 0, 0)'
    });

    var saveButton = document.querySelector('.save');
    var clearButton = document.querySelector('[data-action=clear]');

    saveButton.addEventListener('click', function (e) {
        document.querySelector('[name=signature_data]').value = signaturePad.toDataURL('image/png', 100);
    });

    clearButton.addEventListener('click', function () {
        signaturePad.clear();
    });
   
    var form = $('#sign_form');

    $(saveButton).click(function() {
        $.ajax({
            url: form.attr( 'action' ),
            data: form.serialize(),
            type: 'POST',
            success: function(response, ui) {
                swal({
                  title: "",
                  text: "",
                  icon: "",
                });
                window.setTimeout(function(){window.location.reload()}, 3000);
            },
            error: function(response) {
                console.log('Error!');
            }
        });
    });
});

lawkunchi left a reply on Signature Pad

This is my form

 <form action="{{ route('signature.save') }}" method="POST">
    @csrf
    <div id="signature-pad" class="signature-pad">
    <div class="signature-pad--body">
      <canvas id="signature" name="signature"></canvas>
    </div>
    <div class="signature-pad--footer">
      <div class="description">Sign above</div>

      <div class="signature-pad--actions">
        <div>
          <button type="button" class="button clear" data-action="clear" id="clear">Clear</button>

        </div>
        <div>
          <button type="submit" class="button save" data-action="save" id="save">Save</button>
          <input type="button" class="btn btn-default btn-sm" id="saveSign" value="Add Signature">
        </div>
      </div>
    </div>
  </div>
  </form>

lawkunchi left a reply on Signature Pad

This is my controller 

  public function postSignature(Request $request) {

        $user = $request->session()->get('user');

        $signature = new Signature;

        $data_uri = $request->signature;
        $encoded_image = explode(",", $data_uri)[1];
        $decoded_image = base64_decode($encoded_image);

        $signature->signature = $encoded_image;
        $signature->save();

    }

lawkunchi left a reply on Signature Pad

I got this error when I try to save the signature : Undefined offset: 1

referring to this line
 $encoded_image = explode(",", $data_uri)[1];
26 Oct
1 month ago

lawkunchi left a reply on Signature Pad

@theUnforgiven

Hey man do you mind helping me out on how you approach storing the image from the signature pad. Thanks!

lawkunchi left a reply on Changing Laravel Date Format

I figured it thanks @Yamen

lawkunchi left a reply on Changing Laravel Date Format

Do I use this in the database table because it seems to be not working

$table->date('date')->toDateString();

lawkunchi started a new conversation Get Total Number Of Users

I want to get total number of registered users in my database.

lawkunchi started a new conversation User ID Issue

when a user posts a product. I want to add column on the database table which takes the current auth user id and store it in a column user_id. Thank You!

25 Oct
1 month ago

lawkunchi started a new conversation Changing Laravel Date Format

I want to change larvel date format into something like this(22 Feb 2018)

lawkunchi started a new conversation Populate Data On Chartist JS Graphs

I'm using chartist to populate data graphically but I need help on how I can approach this. For instance I want to get number of users registered against the date they were registered.

Thanks!

lawkunchi started a new conversation Laravel Pagnation

I have a table of users and I want to paginate them in a such a way that I will have an input that will take a number to paginate with. Thanks

<input type="number" name="paginate_number" placeholder="25">