gitwithravish

gitwithravish

Full Stack Developer at Unocoin

Member Since 1 Year Ago

Bangalore, India

Experience Points
65,680
Total
Experience

4,320 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
305
Lessons
Completed
Best Reply Awards
43
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.

Level 14
65,680 XP
Nov
25
3 days ago
Activity icon

Replied to Base Table Or View Does Not Exist

Revisit the question mate. @munazzil

Activity icon

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.

Activity icon

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

Activity icon

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

Nov
24
4 days ago
Activity icon

Started a new Conversation Base Table Or View Does Not Exist

  • I cloned a project from github
  • I changed the database credentials from remote to local in .env
  • Everything works fine.
  • But then I changed the env variables again and try to config cache but got this error
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?

Nov
23
5 days ago
Activity icon

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.

docs

https://laravel.com/docs/8.x/pagination

Activity icon

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.

Activity icon

Replied to Limit The Number Of Records Created Per Day In A Model

  • You can save the max number of posts in a configuration file.
  • Or you can create a middleware that will check the number of posts created and only allow access to the route if the limit is not exceeded
Activity icon

Replied to Limit The Number Of Records Created Per Day In A Model

@astersnake

Well that's simple

$numberOfPosts = Post::whereDate('created_at', Carbon::today())->count();
if($numberOfPosts < 50){
	// create post
}
Activity icon

Replied to Should The Logout Route Be Protected Or Not

try this

Auth::guard('web')->logout();
Activity icon

Replied to My Registration Process Is So Slow [ 5 : 9 Seconds ]

Can you give some more information? Show the controller code for registration

Nov
21
1 week ago
Activity icon

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.

Nov
20
1 week ago
Activity icon

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

  • Events and listeners
  • Sending mails

Video explination

https://www.youtube.com/watch?v=6wZKwJQF7Is

Docs

https://laravel.com/docs/8.x/events

https://laravel.com/docs/8.x/mail

Activity icon

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

  • Events and listeners
  • Sending mails

Video explination

https://www.youtube.com/watch?v=6wZKwJQF7Is

Docs

https://laravel.com/docs/8.x/events

https://laravel.com/docs/8.x/mail

Activity icon

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?

Nov
18
1 week ago
Activity icon

Replied to True Or False Statements

@tomasosho Happy to help :)

Activity icon

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;
}
Activity icon

Replied to True Or False Statements

do you have a many to many pivot table or not?

Activity icon

Replied to True Or False Statements

Can you please tell me what are you trying to find ? Your code does not make sense. Are you trying to see if a logged in user is following some X profile or not ? If no, then please explain in human language, what you are trying to solve here.

Activity icon

Replied to True Or False Statements

it means match not found

Activity icon

Replied to 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;
}
Activity icon

Replied to True Or False Statements

i just assumed that you would have a column with profile_id. Paste in whatever column you actually have. Show me the migrations or model class for the tables involved here

Activity icon

Replied to True Or False Statements

1st approach

You are using the contains method incorrectly. You should use it like this. (tho its not relevant in your case)

...->contains('user_id',$user->id)

Docs https://laravel.com/docs/8.x/collections#method-contains

Do it like this

You cannot compare an object with id, rather compare the profile_id with $user->id

auth()->user()->following->profile_id` == $user->id
Activity icon

Awarded Best Reply on The GET Method Is Not Supported For This Route In API Route ?

Make sure that you are

Activity icon

Replied to Best Way To Get Items Based On User Group ? Help Refactoring

I assume you have 1 pivot table for many to many relationship between user and groups. So you might be having the following table structure

  • users
  • user_group
  • groups
  • assets

In this case, if you have defined your relationships properly, then you can access the assets using User model like this

$assets = User::with('groups.assets')->where('id',$id)->get();
Activity icon

Replied to How To Create A Dynamic Labels In Month In Chart Js

Use the configuration to define it

var chart = new Chart(ctx, {
    type: 'line',
    data: data,
    options: {
        scales: {
            x: {
                type: 'time',
                time: {
                    unit: 'month'
                }
            }
        }
    }
});

Docs

https://www.chartjs.org/docs/master/axes/cartesian/time#time-units

Activity icon

Replied to How To Pass Data To The Modal Form In Laravel

well it would. That's why i used $(this).find('#myWeightedScore').val() where this is the modal element.

Activity icon

Replied to The GET Method Is Not Supported For This Route In API Route ?

No. In postman application's parameter tag. Add key and value as credentials

Activity icon

Replied to The GET Method Is Not Supported For This Route In API Route ?

you need to add api credentials too. Have you added it?

Activity icon

Replied to How To Pass Data To The Modal Form In Laravel

i agree to that. I would postfix id names with a numeric value, just the way you did.

Though it does not really matter. Browser wont throw any error for duplicated those IDs.

Those fields will always be accessed in the context of modal. So within that modal, the ids will always be unique. Though I agree its not a good practice but I don't see any loophole here, so if I am not implementing something big, then I don't stress about it alot and leave it like that :)

Activity icon

Replied to How To Pass Data To The Modal Form In Laravel

@noblemfd Do you have multiple modals ?

Activity icon

Replied to The GET Method Is Not Supported For This Route In API Route ?

@saurav77 saurav what we are asking you is, have you selected the post method or not?

Activity icon

Replied to Reset Tinker's Aliasing

If you want a custom folder to dump files, you have to add it to the autoload-section in composer.json. That way it will be included in the autoload_classmap.php

After that, run the following command.

composer dump-autoload

Check this article for more insights

https://developed.be/2014/08/29/composer-dump-autoload-laravel/

Activity icon

Replied to How Can I Tell Laravel To Look For Public_html Folder And Not Public Folder On SHARED HOSTING?

Please show the following details so that anyone can understand.

  • Your folder structure
  • Error message
  • Do you have a storage link to of storage folder to public folder or you are trying to access app/storage folder @cd4success
Activity icon

Replied to How To Pass Data To The Modal Form In Laravel

@automica yes i know, I am assuming he has a loop of $goals. If not then I dont know what is troubling him.

Activity icon

Replied to The GET Method Is Not Supported For This Route In API Route ?

Make sure that you are

Activity icon

Replied to How To Pass Data To The Modal Form In Laravel

I dont understand what are you having trouble with. Are you not able to access the modal data into the javascript code you have shown? If yes then you can do it this way.

<script type="text/javascript">
$(document).ready(function() {
    $('#comment_emp{{ $goal->id }}').on('show.bs.modal', function (event) {
 	$(this).find('#myRatingLimit').val();
 	$(this).find('#myWeightedScore').val();
    });
});        
</script>

If not, then can you please explain the question better?

Nov
15
1 week ago
Activity icon

Awarded Best Reply on UpdateOrCreate For An Array

You have to loop over your array and execute the updateOrCreate method.

// use database transaction just to ensure 
// database consistency in case of any exception
\DB::transaction(function() use ($languages) {
    
    for($languages as $language) {
      Language::updateOrCreate(['id' => $language->id],[$language]);
    }
});

source

Activity icon

Replied to Wep App + Native Mobile App - What Should I Learn

@zaster As I have mentioned in my first answer,

Once you create your api routes, you should use those routes to fetch data in any of your projects. You will have web.php routes for your web app, but you should request the api urls to show data on the webpage. Same goes for the mobile.

Nov
13
2 weeks ago
Activity icon

Replied to UpdateOrCreate For An Array

You have to loop over your array and execute the updateOrCreate method.

// use database transaction just to ensure 
// database consistency in case of any exception
\DB::transaction(function() use ($languages) {
    
    for($languages as $language) {
      Language::updateOrCreate(['id' => $language->id],[$language]);
    }
});

source

Activity icon

Replied to Put Model::create() Inside A Transaction

What is the question?

Activity icon

Replied to [Chrome, Firefox] Code Block Text Color

Can you properly describe your issue please ?

Activity icon

Replied to How To Access The Authenticated User In A Middleware?

Finally something that make sense. Nice.

Activity icon

Replied to How To Access The Authenticated User In A Middleware?

Show your routes file. What are you doing when you get null in return?

Activity icon

Replied to How To Access The Authenticated User In A Middleware?

@foks are you using web.php routes or any other routes?

In order to use Auth::user(), your routes must be encapsulated within web middleware.

Nov
12
2 weeks ago
Activity icon

Started a new Conversation Laracasts Bug: Gravatar Connectivity Lost.

I had uploaded my profile photo on gravatar but its not visible on laracasts anymore :/

I tried to re upload it but its still not working.

Nov
11
2 weeks ago
Activity icon

Started a new Conversation Global CSS VS Scoped CSS In Vue

Does scoped css in vue components affect performance?

Activity icon

Replied to I Search Lib Similar Vue-notifications For Vuejs3.

@tirtho Please goto https://laracasts.com/discuss and click on Create Discuss and describe your problem there. You will receive tips and solution for your question on that thread of yours.