jlrdw

jlrdw

Member Since 4 Years Ago

Experience Points 376,170
Experience Level 50

0 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 132
Lessons
Completed
Best Reply Awards 389
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.

19 Sep
13 hours ago

jlrdw left a reply on Custom Password Encryption For Authentication

A password should be hashed not encrypted.

jlrdw left a reply on AJAX Code In Laravel Controller

AJAX code in Laravel Controller

The controller has the server side code that sends a response back to the ajax, here are just simple examples.

Ajax will send a get or post or patch, etc, and the actually controller is something like this:

    public function testg() {
        $dogid = Request::input('somevar');
        $dog = Dog::select('dogname', 'comments')
                ->where('dogid', '<', $dogid)
                ->get()
                ->toArray();
        return Response::json($dog);  //  sent back to the ajax call to work with
    

Jquery just simple example, here in view, placed at bottom

<script>

    $(function () {

        $("#testme").click(function (event)
        {
            event.preventDefault();
            var somevar = '3'; // Usually a variable generated by you
                                  // for demo hard coded
            $.ajax({
                url: 'testg',
                type: 'GET',
                data: 'somevar=' + somevar,
                dataType: 'json',
                success: function (data) {
                    $.each(data, function (index, item) {
                        alert(item.dogname);
                         // loop and do whatever with data
                    });
                },
                error: function (err) {
                    alert(err);
                }
            });

        });


    });

But if new to this I suggest take some free tutorials.

This stuff depends a lot on what javascript library you decide to use.

18 Sep
1 day ago

jlrdw left a reply on Print Ticket After Adding A Data

No he said

redirect to a controller that will display the view for that record. Do the printing there.

You print from a view.

Of course it's formatted well.

There is also other JavaScript code floating around online for printing perhaps you can do a search for other ideas on the exact script that works the best.

However the PDF idea I gave you can be printed right away.

Humana health uses that technique when you want to print out a referral it's converted to PDF and there's a print button at upper right.

But that's up to you.

jlrdw left a reply on Print Ticket After Adding A Data

Have you looked at https://www.w3schools.com/jsref/met_win_print.asp

if it works it would require good formatting.

But I am not sure if it would handle if there's more than one page.

jlrdw left a reply on How Can I Restrict Authenticated Users To Those On A Separate Table.

Carry over the username and password to laravel Auth and via code, log in to the laravel app.

Make sure you have Auth routes set up.

See this also: https://laracasts.com/discuss/channels/laravel/authenticate-login-from-an-external-database

jlrdw left a reply on Bitbucket And Compare Two Local Folders With Git

Thanks and if anyone lands here I found a command.

I searched google and stackoverflow 2 more hours.

This show all in working directory not committed yet.

git status --short

// to output to text file in windows

git status --short  > c:\yourfolder\changes.txt

//  not sure about linux and writing to text file.

At least 3 hours, git is tricky.

jlrdw left a reply on Validation For Uploaded CSV Data

Along with that, is validation required, I import data from a bank for example and all is good.

But if the file comes from john doe at least strip_tags or validate each field.

I see a lot of folks dealing with outside API data, yet don't see validation examples.

So it's according to if the data is known good data.

I have also download reports from paypal, I never worried about "validating".

Bottom line be careful.

jlrdw left a reply on GetActionMethod() In __construct Breaks `php Artisan Route:list`

Have you tried passing Route $route in the parenthesis.

But not sure, but I believe this works from a method, but you can try it from constructor.

The API doesn't really cover this in much detail.

jlrdw left a reply on Validation For Uploaded CSV Data

For working with a csv, just make sure file exist, just drop the validation:

if($request->hasFile('csvfile'))
{
   ......
 }

I myself import csv files often.

jlrdw left a reply on Bitbucket And Compare Two Local Folders With Git

As said I have used git for a while, but mostly pull, push, that sort of thing.

I am trying to find one git command that will give me a list of added, modified, and deleted files with folder structure.

This works for deleted:

git diff --diff-filter=D --name-only HEAD

this works for modified

git diff --name-only --diff-filter=M

Or one for just added and modified will work and I can run the deleted command separately.

I have tried at least 50 to 75 combinations of commands from stackoverflow.

I still haven't got one figured out for added files, this DOES NOT work

git diff --name-only --diff-filter=A

Looking to list like:

application/Core/AdminRoutes.php
nbproject/private/private.xml

jlrdw left a reply on Laravel Vapor Deployment Error

Have you checked to see if Taylor offers Support also for this.

jlrdw left a reply on Print Ticket After Adding A Data

One idea would be export to PDF for printing. You could actually look it over just see what you think.

https://github.com/barryvdh/laravel-dompdf

jlrdw left a reply on Authentication In Another Contorller

You should really follow examples in the docs.

https://laravel.com/docs/6.x/authentication

17 Sep
2 days ago

jlrdw started a new conversation Can't See Answers

Suddenly I can't view any of my answers.

jlrdw left a reply on Bitbucket And Compare Two Local Folders With Git

@snapey so just make my local development folder a local git repository also?

Never mind got it:

work directly in git repository

jlrdw left a reply on Nova Questions/recommendations

Nova is mainly an admin area. So just ask yourself this, since Nova uses the models from the laravel app, do you want to or not want to use it.

The main "meat" is laravel.

quote

Nova is a beautifully designed administration panel for Laravel.

end quote

Do you need the things it offers:

jlrdw started a new conversation Bitbucket And Compare Two Local Folders With Git

I use Bitbucket, and currently do the following:

  • Have a development folder under wamp, no git involved
  • Have a git folder where changes are copied to
  • I use Winmerge to do that, works great (it compares changes locally)
  • push the git folder to bitbucket

All works good. But instead of Winmerge is there a way to:

  • Have git do this on local, compare and update the git folder with development folder prior to push?

Or do most of you just have your local development as a local git repository (master)?

16 Sep
3 days ago

jlrdw left a reply on How To Correctly Name A Folder

Me, to avoid any problems I try not to have spaces in a folder name for code.

You could do

  • IndividualSales Cap I and cap S
  • individual_sales
  • etc

https://github.com/alexeymezenin/laravel-best-practices#follow-laravel-naming-conventions

Example for controller:

  • SaleController

jlrdw left a reply on Sluggable Posts Appears More Than Once

Are you sure the extra posts wasn't accidentally inserted while programming all of this.

jlrdw left a reply on How To Chunk Korrectly?

Example shows chunking by id:

quote

DB::table('users')->where('active', false)
    ->chunkById(100, function ($users) {
        foreach ($users as $user) {
            DB::table('users')
                ->where('id', $user->id)
                ->update(['active' => true]);
        }
    });

end quote

https://laravel.com/docs/6.x/queries#chunking-results

jlrdw left a reply on How To Tell If Elastic Search With Scout Is Setup Correctly

Do some searching with known expected results and see how it works.

Chuck Yeager actually flew those planes, no mocking or faker used.

jlrdw left a reply on Get This Where This Exists

I've done this quite a while and have never needed a pivot table however I do use a derived table at times.

https://laracasts.com/discuss/channels/eloquent/calculate-average-of-multiple-fields-eloquent

I generally like normal SQL not active record.

Edit: was curious, here's an S.O. https://stackoverflow.com/questions/36143632/laravel-check-if-data-record-exists-in-any-related-table

You may need to do a join query (or something) to help find mis matched parent child records and do a big cleanup.

Any complex query will take trial and error to work out.

jlrdw left a reply on Send A Data From A Controller In Particular Format.

Not re-writing that, but here is an example from a question a while back.

Maybe you can atapt it as needed.

    public function testJson3()
    {

        $data = '[{  
    "id":18296, "pro_number":232231, "driver":"Bettale", "tractor":null, "dateTime":"2018-08-27 07:00:00", "ShipperCustomerName":"ELECTROLUX HOME PRODUCTS", "ConsigneeCustomerName":"LINN STAR", "ShipperName":null, "ConsigneeName":null
},
{  
    "id":18298, "pro_number":232233, "driver":"Bettale", "tractor":null, "dateTime":"2018-08-28 07:00:00", "ShipperCustomerName":"ELECTROLUX HOME PRODUCTS", "ConsigneeCustomerName":"LINN STAR", "ShipperName":null, "ConsigneeName":null
}]';
        $loads = json_decode($data, true);
        $keys = array_keys($loads);
        //dd($loads);
        for ($i = 0; $i < count($loads); $i++) {
            //echo $keys[$i] . "{<br>";
            foreach ($loads[$keys[$i]] as $key => $value) {
                echo $key . " : " . $value . "<br>";
            }
        }
    }

Outputs:

id : 18296
pro_number : 232231
driver : Bettale
tractor :
dateTime : 2018-08-27 07:00:00
ShipperCustomerName : ELECTROLUX HOME PRODUCTS
ConsigneeCustomerName : LINN STAR
ShipperName :
ConsigneeName :
id : 18298
pro_number : 232233
driver : Bettale
tractor :
dateTime : 2018-08-28 07:00:00
ShipperCustomerName : ELECTROLUX HOME PRODUCTS
ConsigneeCustomerName : LINN STAR
ShipperName :
ConsigneeName : 

It does take a little trial and error at times to work out the exact "loop" needed.

jlrdw left a reply on Protected Fillable Not Working With Vue Axios Patch

Have you tried

$event->information->update($request->all());

jlrdw left a reply on Set Date Format

$table->timestamp('dob') Don't use timestamp for DOB.

Edit: You got me, old post.

jlrdw left a reply on Protected Fillable Not Working With Vue Axios Patch

I kind of thought the issue would point you in the correct direction, sorry it didn't.

jlrdw left a reply on Protected Fillable Not Working With Vue Axios Patch

Try clearing any cache and temp views.

jlrdw left a reply on Is Mass Assignment Dangerous ?

I would think the docs would have something on mass assignment. I found:

Quote

A mass-assignment vulnerability occurs when a user passes an unexpected HTTP parameter through a request, and that parameter changes a column in your database you did not expect. For example, a malicious user might send an is_admin parameter through an HTTP request, which is then passed into your model's create method, allowing the user to escalate themselves to an administrator.

End quote

But there's more

https://laravel.com/docs/6.x/eloquent#mass-assignment

I have never liked:

Input::all .....

I still get one at a time, so it's a little more code, big deal.

jlrdw left a reply on {{$posts->links()}}

Does all work correct if you remove it out of the

@if

And

Instead of image, just post code here enclosed in 3 backticks: like

3 backticks

code

3 backticks

jlrdw left a reply on What Type Of Website Is Evil.com?

How about a "contact us".

jlrdw left a reply on Input Hidden Grabs All The Data

In the top link I gave I showed dealing with just individual check boxes. To me that is the easiest way to deal with them instead of an array.

Forget the Hidden and deal with the check boxes that have a value passed. if a checkbox isn't checked nothing is passed.

15 Sep
4 days ago

jlrdw left a reply on Javascript/JQuery/Ajax Code In Laravel Controller

Write yes, but I wouldn't.

Edit: Was on mobile.

That is for frontend, the view. But you can store strings of code in variables and pass to view.

jlrdw left a reply on Input Hidden Grabs All The Data

if you only want checked don't use hidden input just use the array.

jlrdw left a reply on Input Hidden Grabs All The Data

That's why I showed the links I did, you will have to loop over the request and get the ones checked, Or value of 1.

jlrdw left a reply on Authenticate Without Using Database

See https://laracasts.com/discuss/channels/laravel/custom-authentication-laravel-6

and

https://laracasts.com/discuss/channels/laravel/authenticate-login-from-an-external-database

The problem is if bcrypt wasn't used.

If it is bcrypt you could get information from json and use the username and password to login.

I'd have all update on new login to a bcrypt password, just me.

jlrdw left a reply on Best Laravel Eloquent Tutorial For Searching

LIKE generally works. But there's elasticsearch, I never needed that deep.

In image, I have by date, description, amount, so combo of like, =, etc.

Also there has been past post of filtering eloquent results, I don't have links.

jlrdw left a reply on Laravel

Not sure what was not created. If under (public_html, www, hddocs) you shouldn't need a "link" they just work.

On Linux php artisan storage: link should work.

An alternative on Windows, I've never needed, but once.

If your storage is above htdocs (main laravel) then you could use header to serve image. I do this at times if I for some images.

Something like:

<?php
$basedir = 'your directoru here/storage/app/upload';

$imagedir = $_GET['dir'];
$image = $_GET['img'];

$file = $basedir.'/'.$imagedir.'/'.$image;
$fallback = $basedir.'/fallback.gif';
$size = filesize($file); // File size
$length = $size;
//DETERMINE TYPE
$ext = array_pop(explode ('.', $file));
$allowed['gif'] = 'image/gif';
$allowed['png'] = 'image/png';
$allowed['jpg'] = 'image/jpeg';
$allowed['jpeg'] = 'image/jpeg';

if(file_exists($file) && $ext != '' && isset($allowed[strToLower($ext)])) {
    $type = $allowed[strToLower($ext)];
} else {
    $file = $fallback;
    $type = 'image/gif';
}

header("Accept-Ranges: bytes");
header("Cache-Control: public");
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . $length);
header('Content-Disposition: inline; filename="' . $image . '"');
header("Last-Modified: " . date('r', filemtime($file)));
ob_clean();
readfile($file);
exit(0);

?> 

And a simple:

<img src="<?= 'http://localhost/laravel60/pthru.php?dir=imgdogs&img=' .  $row->dogpic; ?>" alt="" class="image">

In example, from local host,

Main laravel is at:

Bitnami/wampstack-7.3.1-0/apache2/laravel60up

public laravel is at:

Bitnami/wampstack-7.3.1-0/apache2/htdocs/laravel60

Using a proper folder setup:

http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet

Which works on shared or a wamp local. If Using D.O., AWS, etc then they have examples of proper setup.

jlrdw left a reply on What Type Of Website Is Evil.com?

First I hope you check sites before opening with https://www.virustotal.com/gui/home/url

Second, if it's a safe site, why not check their "about" section. Why ask here.

jlrdw left a reply on SaaS How To Write A Clean Subscription System With Specific Functionality?

I guess you decided not to use laravel Spark. Did you at least look over spark.

jlrdw left a reply on How To Start A New Discussion Here In Laracast With Picture?

Put the image on imgur and use img tag as normal here.

On imgur right click the image and see view image to get the URL for the image tag.

jlrdw left a reply on Stop Users Access Your Pages Directly From Url

Query scopes and Auth::user()->id;

If someone changes an ID in the URL it won't work if the query is already calling for a certain ID only.

How a query is written goes hand-in-hand with authorization.

You really have to think RBAC through.

14 Sep
5 days ago

jlrdw left a reply on A Bug In Gate Facade Functionality Or I'm Getting Things Wrong?

Not 100% sure what you are referring to, But sounds like you are logging in and trying to see your data: Have you looked into query scopes.

Admin can see all, but user can see theirs and not someone else's.

https://laracasts.com/discuss/channels/laravel/security-in-controller

Basically uses the Auth::user()->id working hand in hand with authorization.

Sorry if I misunderstood the question.