Software Engineer at Kuala Lumpur
Member Since 10 Months Ago
Kuala Kangsar
4,570 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.
Awarded Best Reply on Table Plus - Homestead, How To Connect?
No, I have never used before. Based on the error you post, probably due to database not created. What is the original value for the first time you ran homestead up?
Replied to Table Plus - Homestead, How To Connect?
No, I have never used before. Based on the error you post, probably due to database not created. What is the original value for the first time you ran homestead up?
Replied to Table Plus - Homestead, How To Connect?
There should be a configuration named "databases", you can list down all the databases you want, and it will auto-create it for you
Example:
databases:
- project1
Replied to Table Plus - Homestead, How To Connect?
Check your Homestead.yaml or any docker file.
Check the IP configuration you set,
Example
ip: 192.168.10.10
memory: 2048
cpus: 2
Your MySQL
Name: Homestead
Host: 192.168.10.10
Username: homestead
Password: secret
Database: project1
Port: 3306
Replied to Update User Table
Maybe you can try mutator, https://laravel.com/docs/8.x/eloquent-mutators#defining-a-mutator
Example
public function setPasswordAttribute(){
$password = request()->has('password') ? Hash::make(request('password')) : auth()->user()->password;
$this->attributes['password'] = $password;
}
Replied to UpdateOrCreate Not Working
Well, it is pretty clear from the documentation. I hope you will spend some time reading it.
https://laravel.com/docs/7.x/eloquent#other-creation-methods
Replied to How To Update Array With Foreach?
Replied to How To Store BelongsToMany?
@vector_rashed The thread was marked solved, and now it's removed.
@oxbir why the best answer is removed? Your issue is not solved yet?
Replied to How To Store BelongsToMany?
Excuse me, you want the foreign key named as user_id or skill_user_id??
If you want named it as skill_user_id, just rename the column user_id to skill_user_id
Replied to How To Store BelongsToMany?
Hey @oxbir, these steps might solve your issue.
1. run command php artisan make:migrate create_skill_user_user_table
2. copy and paste these things
$table->bigIncrements('id');
$table->bigInteger('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('name');
$table->smallInteger('level');
$table->timestamps();
3. execute PHP artisan migrate
Replied to How To Store BelongsToMany?
I can't really understand what are you doing. From my understanding, the relationship should be One to Many instead of Many to Many.
Anyway, just duplicate the migration file of 'skill_user' and rename it to 'skill_user_user' to migrate it.
Replied to How To Store BelongsToMany?
The skill_user_user hasn't created yet in your resumes database.
Replied to 422 (unprocessable Entity) Laravel Nuxt Js Error
Assign data to the variables, do not leave them empty
Replied to Routing With Livewire
You can do whatever you want.
For example, just return the livewire if you want.
return view('livewire.your view');
Replied to Routing With Livewire
If you are using livewire 2.x https://laravel-livewire.com/docs/2.x/upgrading#route-livewire
1.x
https://laravel-livewire.com/docs/1.x/rendering-components#route-registration
Replied to Project Setup On DigitalOcean Npm Errors
hope this article solve your issue https://www.thetopsites.net/article/53091169.shtml
Replied to Project Setup On DigitalOcean Npm Errors
npm run prod or npm run production will create the app.css and app.js files in the /projects/public/
, it will minimize the CSS and js size. For example, app.css will only involve the styling used in your projects.
Replied to Project Setup On DigitalOcean Npm Errors
To be honest, I am not that familiar with npm either, the trick that solved my issue is just executing the command sudo npm run prod
.
Maybe you can try to clear the cache also.
Replied to Project Setup On DigitalOcean Npm Errors
Check the file package.json
, you probably saw things like below, change --no-progress to --progress
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
Replied to Project Setup On DigitalOcean Npm Errors
Hmm, maybe you can enable the progress bar, so that you can know the failure occur in which stage. For example, if you stuck or fail at 92% chuck optimization bla bla bla, it probably due to directory permission issue
Replied to Image On Email Not Showing
Please use a valid domain or IP address to do the testing. Only you yourself can access to the localhost
Replied to Laravel 8: Phpunit Giving Error On Test
https://laravel.com/docs/8.x/database-testing#resetting-the-database-after-each-test
If RefreshDatabase is in used, the database will be cleared after finished executing every test(method).
Replied to Search Not Work Laravel 8x + Livewire
Every valid tag like div, p, table, etc. is considered as an element.
The root element is the top-level element, for example, input and table are the root elements in your file.
Replied to Storage Folder Is Not Showing In The Public Folder After Linking The Path
Check this link. https://laravel.com/docs/8.x/filesystem#the-public-disk
By default, only storage/app/public/
is served as the public directory.
Those files stored in storage/app
will be served as private files.
Replied to Storage Folder Is Not Showing In The Public Folder After Linking The Path
It will only link the directory that viewable publicly, which is storage/app/public
.
Awarded Best Reply on Test API Token Authorization:Bearer
Check this link https://laravel.com/docs/7.x/http-tests#customizing-request-headers
Example
$ response = $ this->withHeaders(['Authorization'=>'Bearer '.$token)->post ('api / store', $ data);
Replied to Test API Token Authorization:Bearer
If you are excepting the response is in JSON
format, please add this to the header
Example
$response = $this->withHeaders(['Authorization'=>'Bearer '.$token,
'Accept' => 'application/json'])//this line
->post ('api / store', $ data);
Also, you can dump the response before asserting the status.
Replied to Test API Token Authorization:Bearer
Check this link https://laravel.com/docs/7.x/http-tests#customizing-request-headers
Example
$ response = $ this->withHeaders(['Authorization'=>'Bearer '.$token)->post ('api / store', $ data);
Awarded Best Reply on How To Click On Image Open The File Dialog
Embed the jquery with this
window.addEventListener('load', function () {
$(document).ready(function () {
//put your script here
});
})
Replied to How To Click On Image Open The File Dialog
Embed the jquery with this
window.addEventListener('load', function () {
$(document).ready(function () {
//put your script here
});
})
Please check the value of DB_CONNECTION in .env, seems like you are connecting to MariaDB instead of MySql
Replied to Carbon\Exceptions\InvalidFormatException Data Missing
Maybe due to invalid/null data passed into Carbon::parse()
Carbon::parse('Hi, I am the bug');
Awarded Best Reply on How To Show The Same Amount After Searching In Value?
Not quite, but I will try my best :)
Change the $request->name
to $request->search
instead?
Replied to How To Show The Same Amount After Searching In Value?
Not quite, but I will try my best :)
Change the $request->name
to $request->search
instead?
Replied to Laravel Jetstream Profile-photos Not Showing
All the files are stored under /project/storage/
, the storage under /public/storage
is the shortcut of the /project/storage/
folder which created by php artisan storage:link
Replied to Laravel Jetstream Profile-photos Not Showing
Is the profile picture stored successfully?
(Window) If yes, these are the steps I fixed it:
storage
created at /project/public/Replied to Return Last Record By Forign_key
Instead of ordering by id
, you should order it by using the DateTime column?
Example: If the updated_at
will update if selected by the student, you should order by the updated_at
Change this
orderby('id', 'DESC')
to
orderby('updated_at', 'DESC')
Replied to API Resource With Pagination
Weird, I have no issue at first, the issue only comes after I adding the code below.
ResourceCollection::withoutWrapping();
Replied to Forget My Password
If you have set up the Mailhog, you can view all the emails at http://localhost:8025
Awarded Best Reply on Factory Created_at
In the factory class, you can initialize the $date
before return.
Example
public function definition()
{
$date = $this->faker->dateTimeBetween('-1 day' );
return [
'created_at'=>$date,
'updated_at'=>$date
];
}
Replied to Factory Created_at
In the factory class, you can initialize the $date
before return.
Example
public function definition()
{
$date = $this->faker->dateTimeBetween('-1 day' );
return [
'created_at'=>$date,
'updated_at'=>$date
];
}
Replied to Factory Created_at
My mistake, use string instead
'created_at'=>$this->faker->dateTimeBetween("-1 day" , now()),
Replied to Factory Created_at
The method is built-in with Faker.
You have to code like this in Laravel 8
'created_at'=> $this->faker->dateTimeBetween(-1, now()),
Replied to Factory Created_at
https://github.com/fzaninotto/Faker#fakerproviderdatetime
$faker->dateTimeBetween('-20 days', now());
Replied to I Have A Request Data But Doesn't Updated In My Database
If possible, just show your controller and model here.
Replied to I Have A Request Data But Doesn't Updated In My Database
primary key
should not be fillable, you can try to code like this:
$validatedData = $this->validate($request, [
'name' => 'required'
]);
$data = $moneyTransfer->update($validatedData);
\Log::info($validatedData);
Awarded Best Reply on Old Data Recreating Every Time A New Data Is Entered In Model
Because you are calling the insert method every time?
This line
$income = Income::create(['project_name_id' => $bill->project_name_id, 'income_amount'=>$prj->remaining_money - $bill->remaining]);
Maybe you should firstOrCreate() ? https://laravel.com/docs/7.x/eloquent#other-creation-methods
Replied to Old Data Recreating Every Time A New Data Is Entered In Model
Because you are calling the insert method every time?
This line
$income = Income::create(['project_name_id' => $bill->project_name_id, 'income_amount'=>$prj->remaining_money - $bill->remaining]);
Maybe you should firstOrCreate() ? https://laravel.com/docs/7.x/eloquent#other-creation-methods