repulsor

repulsor

Member Since 1 Month Ago

Experience Points 370
Experience Level 1

4,630 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 0
Lessons
Completed
Best Reply Awards 0
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.

11 Jul
1 week ago

repulsor started a new conversation Pagination And All()

I am trying to fetch all rows from a table, and use pagination, but seems like

  $category = ProductCategory::all()->paginate(15);

Cant be done as it returns a collection.

What is the right way of retrieving all results and using pagination.

Is it must that I should use a where()? and what condition should I use?

08 Jul
2 weeks ago

repulsor left a reply on Validation : Check If Exists And Value Of Another Field

The above code isnt working, but I dont know why.

It returns the category is invalid. I have verified the category exists in the table, with status=1.

Any idea why it doesnt work?

07 Jul
2 weeks ago

repulsor started a new conversation Validation : Check If Exists And Value Of Another Field

What I am trying to do is, validating an entry, lets say, I am adding a product into the db, and product type should exist in the category table, and the status of the selected category should be active.

How can I do that? Is there already a function that does this, or should I write custom function?

'category' => 'required|exists:productcategory,category,status,1'

Something like this?

26 Jun
3 weeks ago

repulsor left a reply on Updating Other User Profile From Admin Panel

@JLRDW - How do I know which user I am going to update? because all fields are changing on update, and user_id can be changed by editing the inputs ( hidden field or post url)

How to compare or make sure I am updating the correct user?

repulsor started a new conversation Updating Other User Profile From Admin Panel

Guys,

I am wondering what is the right way of doing this.

I have an admin panel, and a page to edit the user profile of others and update them.

Currently the url is in the form

http://localhost/crm/public/admin/editstaff/3

Where 3 is the userid.

Obviously while updating, User_id will be the only thing that will remain constant as admin can change any other data. and I also need the user_id to check if the email is unique and ignore just for the current user_id existence.

I am POSTing user_id as a hidden field. I am sure this is subject to sql injection, or can crash the app or cause data issues if the user mess with the hidden field.

What is the right way of doing this?

Note: I am not trying to edit my user page. I am the Admin, and I am trying to edit other's profile.

22 Jun
1 month ago

repulsor left a reply on Laravel Relations

@AURAWINDSURFING - I get an empty array doing what you suggested. Here is my schema.

Users:

id name

Roles:

id role_id role

role_user

id user_id role_id

Added this in user.php public function roles() { return $this->belongsToMany(Role::class); }

And calling this from controller gives me empty array. $response = User::find(1)->roles;

Any idea why?

21 Jun
1 month ago

repulsor left a reply on Laravel Relations

@MANELGAVALDA - I updated the question. The user may/may not have more than 1 role.

repulsor started a new conversation Laravel Relations

Trying hard to figure this out.

I have 3 tables.

1.Users (id,name) 2.Roles (id,role_id,role) 3.User_roles (id,user_id,role_id)

User can have only single role. Either admin,junior or senior. ( User cannot have more than one role)

Which all relations should I be using? If I use hasone for users and user_roles, I get the data output of user table and user_roles table combined.(I get the role_id from user_roles.) I need to combine it with the roles table also, so I know what role they have.

I have gone through the docs, but it seems too confusing. Please point me in the right direction. I would really appreciate few lines of how to do instead of direct linking. Thanks a ton.

19 Jun
1 month ago

repulsor left a reply on Using Transactions In Laravel User::Create For Setting User Role

@TRAY2 - Yes I did.

Still gets the SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry.

The row is made in the table, but this error is returned. Anyidea why?

repulsor left a reply on Using Transactions In Laravel User::Create For Setting User Role

@TALINON - Just updated the question. Please check.

repulsor left a reply on Issue Submitting Form Data From Bootstrap 4 Modal

Copy paste the generated HTML source here.

repulsor started a new conversation Using Transactions In Laravel User::Create For Setting User Role

What I am trying to do is to set a user role immediately after user creation, and tie them together in a transaction so it rollbacks incase of any issues because it is very crucial.

So far I have reached here trying to get this done.

 protected function create(array $data)
{
    return DB::transaction(function () {
    $NewUser = User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'phone' => $data['phone'],
        'password' => Hash::make($data['password']),

    ]);
    $row_id = $this->create($data)->id;
    $UserRole = UserRole::create([
        'user_id'=> $row_id,
        'role_id' => 1,
    ]);

    });
}

The code has obvious issues,doesnt work, and I would need a little bit help to get it right.

18 Jun
1 month ago

repulsor left a reply on Database Queries In Model Or Controller

How do I place the DB handling in the model as a function, and then just call the function from the controller? Isnt that the right approach. Can you just point me how to call the function from controller?

repulsor started a new conversation Database Queries In Model Or Controller

I am very new to Laravel, learning new things everyday and wants to do things the right way than being hacky.

I am trying to fetch user roles from Roles table. I have a controller, which has function which needs the roles data and then it feeds it to the view.

I have a model for the roles table.

How do I put the codes?

A function in model,which pulls the data, which is called from the controller? (Wont that make a call to itself like this?)

Role Model

public function fetchroles(){ return Role::select('role_id','type') ->where('status',1) ->get(); } }

Controller

Something like

public static function addstaff(){ //Fetch Staff Roles $roles = Call to Model function. ( I dont know how)

Please put light so I can learn :)