Member Since 5 Years Ago
0 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
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.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
Replied to Pure PHP To Laravel Conversion Help
I would say watch some of the laravel 6 from scratch video series and that will give you the understanding of what would be needed.
Use laravel request, and you can use getPdo().
Replied to Laravel Sanctum: Issue Token Upon POST Authentication
https://laravel.com/docs/8.x/sanctum#issuing-api-tokens
Fetch Js is built into modern browsers. You could set up a job that updates front end periodically.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Replied to Should We Use The .env File In Production As Well, And How To Protect It
many users suggest to move the files from the public to the root folder where .env lives
Do not do that, setup like @taylorotwell has in documentation for shared, or one alternative is have main laravel out of public_html, see:
http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/
If something like digitalocean, they have guides.
Replied to Search Docs (Press '/') Does Nothing - Why?
I just type in a search, i.e. collections, etc. I don't know why he has the slash. But the slash brings you to search if somewhere else in docs.
Try it, scroll all the way down on a docs page, and hit the slash. Works on if cursor is on page somewhere.
Replied to Should We Use The .env File In Production As Well, And How To Protect It
Protect by setting up laravel correctly, pointing to public as document root. You should not be able to view .env from browser.
Example:
yoursite.com/.env
If you get error 404, secure, if you can view in browser, not secure. .env is optional however.
Replied to Trace Insecure State Management
If you do a Google, you can find software and companies that check a site's security.
Replied to Laravel Sanctum: Issue Token Upon POST Authentication
You could just use fetch js to reflect changes, because you said it's working now but with a page refresh.
I guess I don't understand suddenly calling it an API when it's the same data. But there are videos on sanctum that would help you.
Awarded Best Reply on Hello Guys, I Don't Know Why Request() Is Not Working When I Am Trying To Submit An Email Form
Give a name in view.
Replied to Does Laravel Support Different Types Of Database Systems?
I would suggest browsing over the documentation, because yes it does exist.
Replied to Groub By Article Title
Replied to Load Routes From A Service Provider
Somewhere in docs he covers the order of things in the laravel cycle, the boot method may be too early for the route in cycle.
Check this KB article: https://support.plesk.com/hc/en-us/articles/213904365
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
You could do similar as above and put them into a collection, where there are a bunch of helper methods:
https://laravel.com/docs/8.x/collections
https://laravel.com/docs/8.x/collections#available-methods
Collections are pretty powerful.
Also I'd consider refactoring the array with meaningful key names; ie:
$collection = collect([
['product' => 'Desk', 'price' => 200],
['product' => 'Chair', 'price' => 100],
]);
Just example.
When you have array's in array's and just numbers for keys you end up with things like having to:
$s = $this->array_flatten($wordsset[3]);
echo $s[2][0];
which gives:
chair
If this is an API, you always want consistent nesting in the data. And better key names if possible:
For example from a previous question:
$currencies = '{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
"EUR": {
"symbol": "€",
"name": "Euro",
"symbol_native": "€",
"decimal_digits": 2,
"rounding": 0,
"code": "EUR",
"name_plural": "euros"
},
"GBP": {
"symbol": "£",
"name": "British Pound Sterling",
"symbol_native": "£",
"decimal_digits": 2,
"rounding": 0,
"code": "GBP",
"name_plural": "British pounds sterling"
},
"INR": {
"symbol": "Rs",
"name": "Indian Rupee",
"symbol_native": "টকা",
"decimal_digits": 2,
"rounding": 0,
"code": "INR",
"name_plural": "Indian rupees"
}
}';
See the consistency and names make a big difference.
Having things like:
[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],
instead of
[["3"],["1"],["chair"]],[["4"],["2"],["seat"]],
To me makes it harder to setup loops.
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
See example here of how I flatten an array, https://gist.github.com/jimgwhit/cbbe5bb0d2556fdc7e37a86d3630239c
$wordsset = [[1],[[["1"],["1"],["scaun"]]],[[["2"],["1"],["stuhl"]]],[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],[[["5"],["la"],["chaise"]]]];
$s = $this->array_flatten($wordsset);
$keys = array_keys($s);
for ($i = 0; $i < count($s); $i++) {
foreach ($s[$keys[$i]] as $key => $value) {
echo $key . " : " . $value . "<br>";
}
echo "-----------------------------------";
echo "<br>";
}
Results:
0 : 1
-----------------------------------
0 : 1
-----------------------------------
0 : 1
-----------------------------------
0 : scaun
-----------------------------------
0 : 2
-----------------------------------
0 : 1
-----------------------------------
0 : stuhl
-----------------------------------
0 : 3
-----------------------------------
0 : 1
-----------------------------------
0 : chair
-----------------------------------
0 : 4
-----------------------------------
0 : 2
-----------------------------------
0 : seat
-----------------------------------
0 : 5
-----------------------------------
0 : la
-----------------------------------
0 : chaise
-----------------------------------
Your loop is not set up correctly.
$s = $this->array_flatten($wordsset[3]); //here
$keys = array_keys($s);
for ($i = 0; $i < count($s); $i++) {
foreach ($s[$keys[$i]] as $key => $value) {
echo $value . "<br>";
}
echo "-----------------------------------";
echo "<br>";
}
Gives:
3
-----------------------------------
1
-----------------------------------
chair
-----------------------------------
4
-----------------------------------
2
-----------------------------------
seat
-----------------------------------
Awarded Best Reply on Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
I even tried:
$wordsset = [[1],[[["1"],["1"],["scaun"]]],[[["2"],["1"],["stuhl"]]],[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],[[["5"],
echo $wordsset[0][0];
die;
Which gives:
1
See if it works in blade
{{ $wordsset[0][0] }}
$wordsset = [[1],[[["1"],["1"],["scaun"]]],[[["2"],["1"],["stuhl"]]],[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],[[["5"],["la"],["chaise"]]]];
return view('testarray.atest', compact('wordsset'));
And in view, just a quick setup:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
{{ $wordsset[0][0] }}
</body>
</html>
And got 1.
Make sure you are calling the correct view, works on my end.
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
I even tried:
$wordsset = [[1],[[["1"],["1"],["scaun"]]],[[["2"],["1"],["stuhl"]]],[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],[[["5"],
echo $wordsset[0][0];
die;
Which gives:
1
See if it works in blade
{{ $wordsset[0][0] }}
$wordsset = [[1],[[["1"],["1"],["scaun"]]],[[["2"],["1"],["stuhl"]]],[[["3"],["1"],["chair"]],[["4"],["2"],["seat"]]],[[["5"],["la"],["chaise"]]]];
return view('testarray.atest', compact('wordsset'));
And in view, just a quick setup:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
{{ $wordsset[0][0] }}
</body>
</html>
And got 1.
Make sure you are calling the correct view, works on my end.
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
That array is correct, do you get error before view is loaded, or after?
Or you calling correct view?
Replied to Hello Guys, I Don't Know Why Request() Is Not Working When I Am Trying To Submit An Email Form
Can you show answered.
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
Where is the error coming from? The array is a correct array. Remember an array is 0 based, starts at 0.
Replied to Laravel Request Is Not Working In Production Model But Work In Local
Check file and class names for case,
Linus is CaSe sensitive:
WIndows Case = case
Linux Case != case.
Replied to Hello Guys, I Don't Know Why Request() Is Not Working When I Am Trying To Submit An Email Form
Give a name in view.
Replied to Undefined Array Key 1, ErrorException While Trying To Pass A Variable To View
What does a dd give you?
Replied to How To Change The Dir Of Components Folder?
You can always put in a pull request to have things changed.
Replied to How Save Records On Tables With Parent->child->child Relationship
Give it a try, if that's what's needed. It worked in my case, each child had a load_id column.
Of course queries were distinguished by if it was a pick or a drop for the truck (LTL).
Just a side note, this was back in my Java days not laravel, but query techniques would be similar.
Replied to How Save Records On Tables With Parent->child->child Relationship
I once had similar, it's basically a double one to many. In my case I had Loads with children: picks and drops.
Replied to How To Change The Dir Of Components Folder?
DDD has more to do with classes, components are view related. You will have to figure out what vendor classes to extend to make it work.
And this is just my opinion, but you would be better off not moving components so that way you are sticking with laravel conventions.
Replied to How To Change The Dir Of Components Folder?
You may need to override by extending a class. But curious, it's already setup to work, why the change?
Replied to Adding Key/value Pair To Every Array Item
Also if whole array applies to
user_id:1,
problem_id:2,
You could make it like a parent child relation:
user_id:1,
problem_id:2,
=============================================
[
{
"user_framework_step_id": 1,
"user_framework_id": 1,
"help_text": "Describe the event or situation that is taking place when they run into the problem."
},
{
"user_framework_step_id": 2,
"user_framework_id": 1,
"help_text": "What problem or challenge do they run into?"
},
{
"user_framework_step_id": 3,
"user_framework_id": 1,
"help_text": "What pain do they experience due to the problem?"
},
{
"user_framework_step_id": 4,
"user_framework_id": 1,
"help_text": "Why does the problem happen in the first place?"
},
{
"user_framework_step_id": 5,
"user_framework_id": 1,
"help_text": "What future state are they trying to achieve?"
}
]
Rather that repeat it in every sub array, just a thought:
Replied to How To Make A Scope With A Raw SQL Query?
public function scopecountPets($query, $petsearch = '')
{
if (ChkAuth::userRole('admin') === 'admin') {
$sql = "SELECT COUNT(petid) as total FROM dc_pets WHERE petname LIKE :sch";
$params = [':sch' => $petsearch . "%"];
} else {
$userid = Auth::user()->id; //Ignore this is custom code
$sql = "SELECT COUNT(petid) as total FROM dc_pets WHERE petname LIKE :sch AND ownerid = :userid";
$params = [':sch' => $petsearch . "%", ':userid' => $userid];
}
$sth = DB::getPdo()->prepare($sql);
$sth->execute($params);
$kount = $sth->fetch(\PDO::FETCH_OBJ);
return $kount->total;
}
Just example....
Awarded Best Reply on POST Request Works With Postman But Not Guzzle 7
Check this, they discuss in detail: https://github.com/guzzle/guzzle/issues/1413
Replied to Intervention Image And FilePond
@www888 so now everything is working? You don't get an error?
Replied to POST Request Works With Postman But Not Guzzle 7
Check this, they discuss in detail: https://github.com/guzzle/guzzle/issues/1413
Awarded Best Reply on Multiple Models In Contoller
It would really be no different than the conventions that you see in the documentation. As he says in one of his videos name it something that makes sense to you but follow conventions at the same time.
Replied to Multiple Models In Contoller
It would really be no different than the conventions that you see in the documentation. As he says in one of his videos name it something that makes sense to you but follow conventions at the same time.
Replied to Stripe Payment Integration Into Laravel
The back and logic goes hand-in-hand with making the payment through the stripe payment Gateway.
Also, look at laravel spark.
Replied to Stripe Payment Integration Into Laravel
I would also look at some of the videos on payments right here on laracast and look at the documentation as well for cashier which works with stripe.
Awarded Best Reply on Laravel For API
Have a look at laravel Passport. But Sanctum should work, read all of the docs.
Replied to How To Prevent The File From Public On Digital Ocean Space?
You can put images anywhere in the file system, (out of web folders). You can serve them with a script. In public, anyone can view them.
Are you wanting:
Replied to POST Request Works With Postman But Not Guzzle 7
I wonder if this line is working:
'csrf-token' => csrf_token(),
Try setting in header.
Replied to Random "Network Has Changed" Error
Android would not be hardwired, I was referring to a user, in home is using Ethernet and wi-fi at the same time.
But I only re-replied since it was asked.
Replied to Random "Network Has Changed" Error
Also see if users who have trouble are using hardwired and Wi-Fi at the same time.
Replied to Doubts About Stack (Breeze, Bootstrap, Vue, ....)
You usually want to have your Auth when creating the project, unless you are going to follow --
https://laravel.com/docs/8.x/authentication#authenticating-users
Reason, some code and files get over written when you scaffold Auth. As far as stacks, you can use any css and js you want. Laravel does not force anything on you.
I'd say before choosing, browse over the various documentation to help decide.
Also remember, @jeffreyway has many free videos.
Replied to How To Configure Eloqent To Throw Exception On Database Timeout?
After making a config change, did you run:
php artisan config:clear
Replied to How To Paginate On Collection ?
Replied to Intervention Image And FilePond
But that is your code, I was just pointing out a possible error.
Replied to Why I Can't Play Any Videos In Laracasts ?
This just came up in another discussion, sometimes it depends on which country.
https://laracasts.com/discuss/channels/general-discussion/cannot-open-free-episodes-courses
Replied to Intervention Image And FilePond
This line looks wrong:
$file->move("uploads/" .,$name_gen); stray dot:
Earned once your experience points ranks in the top 10 of all Laracasts users.