Ravish

Ravish

Member Since 1 Month Ago

India

Experience Points
860
Total
Experience

4,140 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
1
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 1
860 XP
Jan
05
2 weeks ago
Activity icon

Replied to Eloquent Returns Empty Collection

When defining a relationship method, eloquent assume that the column name would be <tablename>_<id>

The column name is assumed as user_id if you define as following,

public function user(){
    return $this->belongsTo(User::class);
}

public function posts(){
    return $this->hasMany(Post::class);
}

Make sure the name of the foreign key column in the Post table is user_id. If not, then you need to specify it in relationship methods. For example, if the id is id_user instead of user_id, then you need to specify it like the following,

public function user(){
    return $this->belongsTo(User::class,'id_user');
}

public function posts(){
    return $this->hasMany(Post::class,'id_user');
}
Jan
04
2 weeks ago
Activity icon

Started a new Conversation Defining Foreign Key Of A Table With Composite Primary Key

I am working on Hotel Booking Portal's user dashboard page. The dashboard allows a property owner to define his property in detail. A property can be assigned to more users with specific access rights, For example, user1 can access part A of the dashboard and user B can access part B of the dashboard.

I am having some trouble creating database design for this.

The following table defines the allocation of properties and users.

`property_user_master`
    - id_property
    - id_user

Following table defines the access rights for a particular user of a particular property

`user_access_rights`
    - id_property
    - id_user
    - id_access_right

Now here, the combination of propertyID and userID has to be referenced from the 1st table. How to define a foreign key that references the primary key of table property_user_master, which is a composite key.

Nov
30
1 month ago
Activity icon

Started a new Conversation Online Hotel Booking Project - Need Some Logic Building Tips To Prevent Code Duplication

Project: Online Hotel Booking portal Page: User dashboard. Here user can add property and details (basic details, rooms, amenities, etc.)

Problem : In the User Dashboard page, we ave several pages (Basic details, policies, room details, images, etc). One controller for each controller. For each controller, I am using a middleware VerifyPropertyUserMiddleware. Now I require fetching Property model in every single controller.

$ppt = PropertyMaster::findOrFail($pID);

Solutions that I can think of

  1. Create this instance in middleware and pass it to the controller. (but I think middlewares are not supposed to do this job)
  2. Create a trait, inside that trait create a method getProperty (but code duplication is still a problem as I will have to call the method in every controller)
  3. Use sessions. But still, code duplication is still there because in every controller I will have to check whether the laravel session has $ppt variable or not.
Activity icon

Replied to Passing Data From Middleware To A Controllers Constructor?

I am having a similar problem. I am working on an online hotel booking project. We have a user dashboard in which there are multiple tabs. One controller for each tab. Now every controller requires an instance of Property model. The primary key (id) of this model is passed in the URL like - www.mydomain.com/xyx/3. Here 3 is the ID. I require an instance of the property model in every controller. I have a middleware that validates the user and property to make sure that users can access their property only. I was thinking I will create an instance in the middleware and pass it to the controller to prevent code duplication. What another approach should I use?

$ppt = PropertyMaster::findOrFail($pID);
Nov
28
1 month ago
Activity icon

Awarded Best Reply on JQuery Validator

Try this

let validator = $('#category-form').validate({
        rules: {
            name: {
                required: true
            },
            description: {
                required: false
            }
        }
    });
$('#create-category').click(function(event) {
        event.preventDefault();

        $(this).attr('disabled', true);
        $(this).text('Processing...');

        if (validator.form()) {
            $.ajax({
                type: 'post',
                url: '{{ route('categories.store ') }}',
                data: $('#category-form').serialize(),
                success: function(data) {
                    console.log(data)
                },
            });
        }
    });

Create validator variable, and use it to validate form as validator.form()

Activity icon

Replied to JQuery Validator

@mvd The point here is, he wants to send the form using ajax request. So he is preventing the form from automatically being submitted.

Activity icon

Replied to JQuery Validator

Try this

let validator = $('#category-form').validate({
        rules: {
            name: {
                required: true
            },
            description: {
                required: false
            }
        }
    });
$('#create-category').click(function(event) {
        event.preventDefault();

        $(this).attr('disabled', true);
        $(this).text('Processing...');

        if (validator.form()) {
            $.ajax({
                type: 'post',
                url: '{{ route('categories.store ') }}',
                data: $('#category-form').serialize(),
                success: function(data) {
                    console.log(data)
                },
            });
        }
    });

Create validator variable, and use it to validate form as validator.form()

Nov
27
1 month ago
Activity icon

Replied to How To Add Input Field Using JS ?

@rodrigo.pedra Thanks! Looks like a well-organized way of dealing with such tasks

Activity icon

Replied to JQuery Validator

@paduraruionutandrei Approach 1 :

$('#formID').submit(function(){
    e.preventDefault();
    
    //disable button    
    //add text to proccessing...

    //if not valid return otherwise proceed further
    if(!$(this).valid()) return false;

    //your ajax code
    $.ajax({...});
});

Approach 2 : You can use jquery validator's submitHandler method. This method will be invoked only if the form is validated

$('#formID').validate({
    //validation rules go here

    submitHandler: function(form){
        //your ajax code
        $.ajax({...});
    }
});

https://stackoverflow.com/questions/11469616/jquery-form-validation-before-ajax-submit

If you don't want to use any of these approaches, then please share the HTML code snap, so that I can understand it better

Activity icon

Replied to Multiple Projects On Same Database.

@shafiqulislam @zachleigh I am having a similar kind of problem with my project. The project is divided into many sub-projects. I am having some problems understanding what you guys are discussing. Communication via API means I will have to develop an API and rather than using eloquent methods. Is it !?

Activity icon

Started a new Conversation Multiple Projects That Requires Same Database And Model Layer

I am working on a corporate project. We have multiple modules (4 to 5) whichhave to be connected to the same database.

But some of the modules will be uploaded on subdomains. e.g. www.xyz.com, www.admin.xyz.com

And some on completely different domains. e.g. www.xyz.com, www.abc.com

But everything is a part of a single project. The database is common.

What is the best way to handle such kind of project?

There is a similar discussion on the following link https://laracasts.com/discuss/channels/tips/multiple-projects-on-same-database

But I am a beginner, so I am not able to understand it properly. If anyone can explain to me with little more details, it would be very helpful!

Nov
25
1 month ago
Activity icon

Replied to Update Upgrade Laravel Then Framework (guide)

It was helpful. Thanks

Activity icon

Replied to Enable Ignition After Laravel 6 Upgrade

@jlrdw What do you mean by a complete upgrade? I am working on a corporate project, and all I can do is "update", right?

Activity icon

Replied to Enable Ignition After Laravel 6 Upgrade

Exactly @nakov

I did some quick searches on google and found out the solution.

Step 1: Install facade/ignition package composer require --dev facade/ignition

Step 2: remove filp/whoop (old error handling package)

Activity icon

Replied to Enable Ignition After Laravel 6 Upgrade

Can you please guide me on how to install it manually, please?