Member Since 1 Year Ago

Nepal

Experience Points
23,600
Total
Experience

1,400 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
156
Lessons
Completed
Best Reply Awards
11
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 5
23,600 XP
Feb
10
2 months ago
Activity icon

Replied to Laravel Sail: How To Add ExecutablePath In VSCode Settings

Nope. Have not found any solution yet. I instead installed multiple PHP Versions (7 & 8) in Local System with Chocolatey. And, switch executablePath between them per project as required.

Jan
08
3 months ago
Activity icon

Replied to Permanent NoSQL Storage

Instead of Cache drivers, go for NoSQL database. It seems like you want to store old data as a backup and clear your SQL table.

You can use this package: https://github.com/jenssegers/Laravel-MongoDB to use MongoDB in Laravel.

And Laravel Scheduler: https://laravel.com/docs/8.x/scheduling to timely store data in Mongo and clear old data from SQL database.

https://www.mongodb.com/cloud/atlas

Jan
07
3 months ago
Activity icon

Replied to Map The User Into Groups From Id

You can use Chunking feature of Laravel Collections. https://laravel.com/docs/8.x/collections#method-chunk

return User::all()->chunk(100);

// [ [User1, User2, ...., User100], [User101, ...] ]
Jan
05
3 months ago
Activity icon

Replied to How Can I Give Multiple Condition In @can Laravel

https://laravel.com/docs/8.x/authorization#via-blade-templates

@canany(['user_manage', 'client_manage'], $post)
    <!-- The current user can update, view, or delete the post... -->
@elsecanany(['view'], \App\Models\Post::class)
    <!-- The current user can view any post... -->
@endcanany
Dec
23
3 months ago
Dec
20
3 months ago
Activity icon

Replied to How To Check Logged-in Users Count?

For Normal and Rough approach you could do something like this. https://laracasts.com/discuss/channels/laravel/count-cached-users (Although it will have some overhead)

Alternatively, Web Socket can be used to get active users and verify the logged in with Private Channel.

Dec
10
4 months ago
Activity icon

Replied to Laravel Sail: How To Add ExecutablePath In VSCode Settings

Yep, I have installed Remote-WSL as well as Docker extension. Everything else is good and working.

It is just the php.validate.executablePath that I want to use from wsl/docker. For now, the only solution seems to be is install PHP in local system and use it for this specific settings. (Plus PHP Intelephense)

Activity icon

Replied to Laravel Sail: How To Add ExecutablePath In VSCode Settings

This is what the Reveal in Explorer gives: wsl$/Ubuntu/home/username/example-app/php.bat. It does not work either.

Activity icon

Replied to Laravel Sail: How To Add ExecutablePath In VSCode Settings

@sinnbeck

I created a php.bat file in root of my project with this in it.

@echo off
sail php %*

And this in the VSCode settings.json I have:

{
  "php.validate.executablePath": "./php.bat"
}

It then shows Notification with spawn ./php.bat EACCES, I cannot verify if it worked or not. It does not validate the PHP code at all.

Dec
09
4 months ago
Activity icon

Started a new Conversation Laravel Sail: How To Add ExecutablePath In VSCode Settings

So, I just setup a fresh project with Laravel Sail. (Windows 10, WSL2, Docker)

Everything are running perfectly. But, in VSCode the PHP Language Feature requires php.validate.executablePath in settings. How to put the PHP path from Docker in this settings.

And, also PHP is not installed in WSL. When, I run php -v in WSL it throws Command not found. But, sail up works fine. (It Seems to be running standalone, so how to get the executable path???)

Nov
18
4 months ago
Activity icon

Replied to Laravel Fails In First Authentication Intent

I have seen this issue in many Laravel & Django Projects. Could not figure out the main problem. But, for me Disabling Ad Blocker worked. (Otherwise I had to resubmit the form)

Nov
11
5 months ago
Activity icon

Replied to Global CSS VS Scoped CSS In Vue

Directly from the docs. https://vue-loader.vuejs.org/guide/scoped-css.html#also-keep-in-mind

Scoped styles do not eliminate the need for classes. Due to the way browsers render various CSS selectors, p { color: red } will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in .example { color: red }, then you virtually eliminate that performance hit.

Nov
09
5 months ago
Activity icon

Replied to Search Input And JWT Token

Is the logout issue while searching, theoretical or did it happen?

Providing blacklist_grace_period in config/jwt.php should help. It is made for similar situation.

https://github.com/tymondesigns/jwt-auth/blob/develop/config/config.php#L238

Also, I had it wrong before, refresh() without true also invalidates token immediately.

Activity icon

Replied to Search Input And JWT Token

@davidsprauel This package? tymondesigns/jwt-auth

I assume you have set ttl as 20 in config/jwt.php and you use:

// Pass true as the first param to force the token to be blacklisted "forever".
$newToken = auth()->refresh(true);

But, instead I would suggest to remove the true from 1st param (Because, it will be expired in 20 minutes anyway). So, the old token can still be used for that quick search case.

And also again, Storing Whitelist of Token in DB and checking if it exists is another level of authentication check.

Activity icon

Replied to Search Input And JWT Token

Why Refresh Token in every single request? Would be better to refresh, if token is expired (with TTL).

Also, It is probably better to Whitelist active tokens in DB. Then, validate those tokens and check if exists in database. And remove them on logout or expiry or created_at > some_days rather than Blacklisting (which will grow to be a lot, especially if doing on every single request).

Activity icon

Replied to Opinion: Front-end Development Sucks These Days

Sometimes we should be ready to say "NO".

We cannot say Yes to all new Projects that we are offered, where we need to learn certain new/old frameworks, refactor others code (Even if it may pay good).

You just Learn a certain frameworks you love and feel comfortable and create projects with it. And, slowly learn other languages, frameworks (This just happens itself...while tweaking others code etc.)

In my view the main problem is Job Descriptions we see, where they put multiple frameworks, languages as required. (Like Vue.js + Angular or PHP + C#. Why both? Isn't it.)

Experienced in One is way better then Cluttered Knowledge.

Nov
08
5 months ago
Activity icon

Replied to Spamm Blocker Slowing The Site Down

I also had implemented similar spam filter and was getting slow.

I have now instead implemented Captcha + Form Honeypot and spam are rare.

For Honeypot I use height:0; instead of display:none;.

.....
<div style="height: 0;opacity: 0;margin: 0;padding: 0;pointer-events: none;">
  <input id="dummy" type="text" name="dummy" placeholder="Type Nothing">
</div>
.....
Nov
07
5 months ago
Activity icon

Awarded Best Reply on Laravel Route's UPDATE Method Is Not Working (AJAX Environment)

You need to take another look at this: https://laravel.com/docs/8.x/controllers#actions-handled-by-resource-controller

The URL is Restful i.e. we do not need product/update/1 it should be product/1 with method PUT/PATCH and it will trigger the update function. Similarly, product/1 with DELETE will trigger destroy.

 $('#mainCatAddEditForm').ajaxSubmit({
      url: "{{url('maincat')}}/"+id;
      type: 'POST',
      data: {
          "name": name,
          "description": description,
          "_token": "{{ csrf_token() }}",
          "_method": "PUT"
      }
})
Activity icon

Replied to Laravel Route's UPDATE Method Is Not Working (AJAX Environment)

You need to take another look at this: https://laravel.com/docs/8.x/controllers#actions-handled-by-resource-controller

The URL is Restful i.e. we do not need product/update/1 it should be product/1 with method PUT/PATCH and it will trigger the update function. Similarly, product/1 with DELETE will trigger destroy.

 $('#mainCatAddEditForm').ajaxSubmit({
      url: "{{url('maincat')}}/"+id;
      type: 'POST',
      data: {
          "name": name,
          "description": description,
          "_token": "{{ csrf_token() }}",
          "_method": "PUT"
      }
})
Activity icon

Awarded Best Reply on Laravel Resources Vs Custom Controller Functions

It is a good practice to stick with resource, so that the url, route name, action and method follows general convention. https://laravel.com/docs/8.x/controllers#actions-handled-by-resource-controller

So, if you are working in a team, everyone can easily work and understand (Rather then having different route names and method to remember)

But, sometimes you might also want to use custom routes and there is nothing wrong about it.

Activity icon

Replied to Laravel Resources Vs Custom Controller Functions

It is a good practice to stick with resource, so that the url, route name, action and method follows general convention. https://laravel.com/docs/8.x/controllers#actions-handled-by-resource-controller

So, if you are working in a team, everyone can easily work and understand (Rather then having different route names and method to remember)

But, sometimes you might also want to use custom routes and there is nothing wrong about it.

Activity icon

Replied to Restart Supervisor During Deploy?

@vkronlein

https://medium.com/@taylorotwell/properly-deploying-queues-on-forge-5abe1eac6d1c

The queue:restart command will stop all of the queue workers running on the machine and let Supervisor restart them, ensuring they are using the fresh code you just deployed.

Activity icon

Replied to Defining Constant / Object Globally For The App

You could also implement Multi Tenancy. https://tenancyforlaravel.com/

$tenant = Tenant::create();
$tenant->createDomain([
  'domain' => 'firstexample.com',
  'name' => 'First Example Store',
  'theme' => '#323232',
]);

Then Access the Current Tenant with

tenant();
tenant()->name;
Nov
06
5 months ago
Activity icon

Awarded Best Reply on Does Laravel Check Hashing Password Is Same With Password_verify?

With the following test, all returns true. So, it should work properly.

use Illuminate\Support\Facades\Hash;

Route::get('/', function (){
  $pass_hash = password_hash("123456", PASSWORD_DEFAULT);
  $laravel_hash = Hash::make("123456");

  // Comparing Hash Reverse eachother
  echo password_verify('123456', $laravel_hash); // True
  echo Hash::check('123456', $pass_hash); // True

  // Comparing Hash Normal
  echo password_verify('123456', $pass_hash); // True
  echo Hash::check('123456', $laravel_hash); // True
});
Activity icon

Replied to Does Laravel Check Hashing Password Is Same With Password_verify?

With the following test, all returns true. So, it should work properly.

use Illuminate\Support\Facades\Hash;

Route::get('/', function (){
  $pass_hash = password_hash("123456", PASSWORD_DEFAULT);
  $laravel_hash = Hash::make("123456");

  // Comparing Hash Reverse eachother
  echo password_verify('123456', $laravel_hash); // True
  echo Hash::check('123456', $pass_hash); // True

  // Comparing Hash Normal
  echo password_verify('123456', $pass_hash); // True
  echo Hash::check('123456', $laravel_hash); // True
});
Nov
04
5 months ago
Activity icon

Replied to How To Install Redis In Windows 10 ?

I suggest looking into Windows Subsystem for Linux (WSL). Basically, you run Linux System inside of Windows 10 (Not like a Virtual Machine, so it won't be slow at all). Then, install and run Redis in the Linux Subsystem using the Terminal and use that IP and Port directly as if it was running on windows itself.

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Activity icon

Replied to Auth::attempt Always False?

In Laravel you do not store password as String. The Password needs to be Hashed before saving to the database. Also, Email is used to authenticate. (Unless you changed it to name yourself)

Instead of saving string password do this to generate Hash and store the hash in the password field.

use Illuminate\Support\Facades\Hash;
return Hash::make('admin'); // store this to password field

Then do this:

Auth::attempt(['email' => '[email protected]', 'password' => 'admin']);
Oct
28
5 months ago
Activity icon

Replied to $image_tmp = Input::file('image');

You have multiple options:

(1)

// No need Importing anything
public function store() 
{
    $image_tmp = request()->file('image');
}

(2)

use Illuminate\Http\Request;
public function store(Request $request) 
{
    $image_tmp = $request->file('image');
}
Oct
25
5 months ago
Activity icon

Replied to How Can We Protect Uploaded Images And Pdf Files In Laravel

My suggested approach.

For Publicly viewable Files Store it with 'public' filesystem disk.

if(request()->hasFile('image') && request()->file('image')->isValid()){
     $post->image = request('image')->store('post', 'public');
}

So if you visit myurl/storage/post/filename.jpeg it is visible. To get url Storage::url(Post::first()->image)

For Private files store without 'public' filesystem disk or 'local' by default.

if(request()->hasFile('image') && request()->file('image')->isValid()){
     $post->image = request('image')->store(auth()->user()->id.'/post');
}

The path is myurl/user_id/post/filename.jpeg. But this path is not served from public so is hidden.

Then, finally to access the file create a route in web.php that takes the image url as param.

// Where url can be generated with Storage::url(Post::first()->image)
Route::get('storage/{url}', function ($url) {
    $user_id = request()->segments()[1] ?? null; // get user_id from url
    if (!$user_id || !Storage::exists($url) || $user_id != auth()->user()->id){
       abort('404');
    }
    $path = storage_path('app' . DIRECTORY_SEPARATOR . $url);
    return response()->file($path);
})->where(['url' => '.*']);

Note: If you use AWS S3 then look into File Visibility. https://laravel.com/docs/8.x/filesystem#file-visibility

Oct
13
5 months ago
Activity icon

Replied to How Pass Param Route If The Param Is On JS File

If you are using Ajax or Axios, you could do something like:

$.ajax({
        url: "/generate/pdf",
        type: "post",
        data: {
		"id": [1,2,3,4]
	},
        success: function(res) {
            console.log(res);
        }
});

Or, If you are using normal Form Request:

In a hidden input field set value to array of ids.

<input type="hidden" value="[1,2,3,4]" name="id"/>

Then, in the Laravel decode it as:

$ids = json_decode(request('id'));
Activity icon

Replied to The Profile Picture In Jetstream Dashboar

In your config/jetstream.php, uncomment Features::profilePhotos().

In the initial release of Laravel Jetstream this was enabled by default. But, now according to community recommendation this has been disabled by default. Just uncomment this to enable it.