3,000 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.
Started a new Conversation Any Good Way To Organise Localisation Files?
I want to organise locale files stored in resources/lang/en
for different api versions and within that for different modules/categories.
Any good practices or tips?
Started a new Conversation How To Automatically Restart A Console Command If It Dies
I am running multiple console commands in production. Some commands including jobs processor dies somehow. I want to restart that process if it dies.
What could be a clean way to do this?
Replied to How Can I Add Flash Message In Delete Action?
what about the second option?
session()->flash(...)
Replied to How Can I Add Flash Message In Delete Action?
Laravel autoload the session facade, you can see it in app.php
. You can directly import it like this.
use Session;
Session::flash('key','value');
Or you can use the accessor
session()->flash('key','value');
Replied to Accessing Related Model In Boot Method
Can you provide some context so that I can understand better and suggest accordingly ?
When and in what scenario are you using this code snippet and with what model and relationship?
Replied to Inertia Js Vue Laravel Accordion
Its not difficult to do. All you have to do is
You can also show a spinner or loader gif or something like that so that the user gets a feedback that something is being loaded from the server, otherwise he might keep clicking on the header, resulting into unnecessary ajax requests.
There are other ways as well
Search How to load dynamic data/components in vue
Replied to Accessing Related Model In Boot Method
I don't know what exactly you are trying to do, but usually you wanna use an event inside booted()
method, depending on the purpose of your code. For example,
protected static function booted()
{
parent::booted();
self::retrieved(function($model){
$model->relationName->id;
});
}
https://laravel.com/docs/7.x/eloquent#events
Started a new Conversation Get Eloquent Model With ALL Relationship Models
Is there any way to fetch model with all its relationships without needing to mention every single one of them within with()
method?
Replied to Duplicate Submit When Browser Back After Login
Do you mind explaining the purpose of such approach?
Replied to How To Debug Wrong Matching Id?
Show the values of $bank_list
and $redemptions_prod
variables.
Replied to Redirect Back After Login In Laravel 8
Replied to JQuery: How To Change The Style Of A Div Which Exists Before The Element With A Specific Class Name?
$('.table-responsive').prev().css('display','none');
Checkout the following link for better understanding
https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_traversing_prev
Replied to How To Validate Image In Edit Form If There Is No Image Is Selected
I would rather suggest you to create two request classes. ProductCreateRequest
and ProductUpdateRequest
public function rules()
{
return [
'name' => [ 'required' ],
'image' => [ 'required','image','mimes:jpg,png,jpeg' ],
];
}
Here, you simply put the image rule as nulllable. So image will only be validated if it exists
public function rules()
{
return [
'name' => [ 'required' ],
'image' => [ 'nullable','image','mimes:jpg,png,jpeg' ],
];
}
Replied to Compact(): Undefined Variable
The issue could be with php versions as well. I degraded my php version from 7.4
to 7.1
and it got resolved !
Replied to Implementing A Shopping Cart In Laravel 7
There are already a lot of resources available. Follow it
https://webmobtuts.com/backend-development/creating-a-shopping-cart-with-laravel/
https://www.youtube.com/results?search_query=laravel+shopping+card+tutorial
Umm... simply use grids?
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
You may run into image height problem. You can resolve it by the followings
<div class="row gallery">
<div class="img col-md-4" style="heigh:300px; background-image: url(...)"></div>
<div class="img col-md-4" style="heigh:300px; background-image: url(...)"></div>
<div class="img col-md-4" style="heigh:300px; background-image: url(...)"></div>
<div class="img col-md-6" style="heigh:600px; background-image: url(...)"></div>
<div class="img col-md-6" style="heigh:600px; background-image: url(...)"></div>
</div>
.gallery img{
width: 100%;
backgrouund-size: cover;
background-position: center;
}
Started a new Conversation Best Practices To Debug In Production
I am having some hard time debugging api and project in production. My laravel version is old (5.4), so i cannot use debugbar as well.
In local we can quickly dd()
variables and see whats going on.
But in production, I feel stuck. Everytime i have to do some changes, push, deploy and test. This is very tedious.
Can anyone experienced suggest good practices/packages ?
Started a new Conversation Dynamic Request Class Injection In Laravel
I have a custom request class which is getting longer and longer with project development.
An API endpoint is expected to have multiple types ofinput
. Any one is expected to be received at once.
According to the input
, the validation rules are being constructed.
Right now I am having a long list of swith-cases to construct validation rules.
I want to create multiple requests classes for each case and dynamically inject appropriate request class to the controller method. Note that I cannot create multiple api endpoints.
Is there any good suggestion to handle this?
Replied to Property [Musd] Does Not Exist On This Collection Instance.
unable to understand your question mate
Replied to Symfony Process: Command Not Found
Tried but no luck.
It returns the appropriate paths.
[edit]
Error Output:
================
env: node: No such file or directory
Replied to Symfony Process: Command Not Found
@nakov basically want to execute shell command from php.
It worked just fine using shell_exec
, but the user input is expected to have any valid UTF-8 character, so its not possible to sanitise the input i guess.
So my best chance is to use something like Process
.
I would appreciate if you can suggest any alternatives as well.
Thanks
Replied to Symfony Process: Command Not Found
Hey, thanks for reply @nakov
the user on your application server might be different than the default from your terminal
I executed whoami
from Process()
and terminal. Both returns same username only.
And trying to run any other util that is part of your /usr/local/bin?
I ran two commands from /usr/local/bin
Process(['npm','v']); //command not found
Process(['httpd','v']); // worked
How do I debug this, I don't understand.
One of my friend @sinnbeck tested the same thing on linux i guess, it worked just fine. Could it be an OS issue?
Started a new Conversation Symfony Process: Command Not Found
I am using Symfony Process component.
I have installed this.
resolution
command works just fine in my terminal. However I am not able to use it with Process()
$process = new Process('resolution');
$process->run();
The command "resolution" failed.
Exit Code: 127(Command not found)
I tried to echo the$PATH
variable.
$process = new Process('echo $PATH');
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
The resolution command is stored in /usr/local/bin , so it should work i believe.
All the solutions on the internet points towards checking the $PATH which does not seem like an issue.
Even if I write entire path of the command, it wont work with Process component. It works in normal terminal just fine
$process = new Process('/usr/local/bin/resolution');
$process->run();
The command "resolution" failed.
Exit Code: 127(Command not found)
I have tested my code with different laravel versions as well (5.4 and 8). Facing the same issue
Replied to Gitignore Advise For Laravel Please
I believe the .gitignore
files ships with laravel project template by deafaut. Why do you need to configure it like this by yourself?
Started a new Conversation Best Way To Read Config File Within A Service Provider
I have a custom package like this in my project
App
Services
MyPackage
Exceptions
config
config_to_be_published.php
config_for_internal_use.php
Facades
ServiceProvider.php
Service.php
Here, what is the best way to access config_for_internal_use.php
within Service.php ?
Usually in laravel we would use config()
to read the configs.
How should I go about this?
Replied to Throttling: Different Rate Limit For Different Users.
I will take a look into it. And that laravel episode was helpful. Thanks !
Started a new Conversation Throttling: Different Rate Limit For Different Users.
Framework version: 5.4
I want to set different rate limits for different types of users. Any tips?
I assume there is no dedicated way to do it.
Started a new Conversation How To Sanitise User Inputs For `shell_exec()`
shel_exec("command -flag1 $data1 -flag2 $data2;")
$data1
and $data2
properly?.
,-
and _
I am bound to go with this approach only, so I want to minimise the risk as much as possible.
Can anyone good with linux help me out here?
Replied to Base Table Or View Does Not Exist
Well yeah I did that only and it worked. But I put put out this question to understand why it happened.
Replied to Base Table Or View Does Not Exist
As I have mentioned, the issue is it is trying to access oldBD.table, but I do not have that db in my server. I have my target database with other name and it has everything that is needed. I am trying to clear the cache so that the app can connect to the database of which credentials I have added in the env. @tray2
Replied to Base Table Or View Does Not Exist
well the problem with the migrations is that they are not maintained by the original developers. So the database is cloned directly from server to localhost @marianomoreyra
Started a new Conversation Base Table Or View Does Not Exist
.env
Base table of view does not exist...
I tried to run the following commands
php artisan cache:clear
php artisan config:cache
But still instead of rewriting the cache, artisan was throwing the same error. It is trying to make db request by using old env variables. How do I fix this?
Replied to Laravel Accessors On Query Builder
Well, I don't think you are sending 500 records in one api request, are you? You should paginate your eloquent queries like this.
Replied to Limit The Number Of Records Created Per Day In A Model
That is not an efficient solution here.
Imagine that a user tries to create the post but it fails because of some validation error. Now user will correct the error and send a 2nd request to create a post and this time the post will be stored. So user actually accessed the route 2 times but only 1 post was created.
So the number of route visits cannot not represent the number of post creations.
Replied to Limit The Number Of Records Created Per Day In A Model
Replied to Limit The Number Of Records Created Per Day In A Model
Well that's simple
$numberOfPosts = Post::whereDate('created_at', Carbon::today())->count();
if($numberOfPosts < 50){
// create post
}
Replied to My Registration Process Is So Slow [ 5 : 9 Seconds ]
Can you give some more information? Show the controller code for registration
Replied to Foreign Keys
Short answer, No. Unless you have a very good reason to do it or your primary key in the reference table is represented by a string.
Awarded Best Reply on A Good Way To Notify Users Through Email Of Some Event?
Its very simple. Learn these two things to implement it in laravel
https://www.youtube.com/watch?v=6wZKwJQF7Is
Replied to A Good Way To Notify Users Through Email Of Some Event?
Its very simple. Learn these two things to implement it in laravel
https://www.youtube.com/watch?v=6wZKwJQF7Is
Replied to How To Create A Dynamic Labels In Month In Chart Js
@gitwithravish can you please put your code between triple quotes so that i can read?
Awarded Best Reply on True Or False Statements
So try to understand whats the problem here. You are trying to search a value in an array of collections. It doesn't work like the way you have implemented.
Rather this might work for you.
$result = auth()->user()->following()->where('user_id',$user->id)->first();
if($result){
$follows = true;
}else{
$follows = false;
}