Simple Friend System Codeigniter - codeigniter

guys I just want to ask how to make a simple friend system? I already make a table for the friend list and request and i can already add friend but my problem is there is only one account i can add. How could i solve it? If somebody knows please tell me.

Surely you just need a table of users and then a join table called something like users_to_friends where you store the user_id and the user_id of their friend

Related

Update entity with OneToMany relationship with JPA/Spring

I've been researching this for a while and still couldn't find a satisfactory answer for my problem.
I have an entity on my postgres DB (product) that has a ManyToOne relationship with another entity (Dun).
Each product may have N duns.
On my PUT endpoint, the desired behavior would be:
Every time I update a product, it replaces all the duns with the ones provided on the endpoint.
Is there any way to handle it automatically by Hibernate/JPA?
In order to make it easier to test and explain the issue, I've uploaded a project on Github on the following link https://github.com/brunapereira/jpaexample
If there's no way to handle it automatically by JPA, what's the best way to solve it with code?
Thanks in advance,
First, you need to remove Duns by product id, then get the product by id, add the new duns then save back.

Parse js sdk, How do you query many to many in document DB?

In the Parse js guide it says:
For example, a User may have many Posts that she might like. In this case, you can store the set of Posts that a User likes using relation. In order to add a Post to the “likes” list of the User, you can do:
var user = Parse.User.current();
var relation = user.relation("likes");
relation.add(post);
user.save();
My use case is actually this exact setup. We have Users and they can "like" 0-many Posts, so I set it up exactly as stated above. My issue now is that for a given Post or set of Posts, I need to query how many users have liked each Post. I'm having trouble figuring out how to query for that... Can someone help me out? I'm not sure if this is a limitation or if I just don't know enough to figure this out. I've thought about storing a counter on the Post itself and using increment() and decrement() each time a User likes or unlikes a Post, but I'd rather not if I can get away with it.
There are a couple of ways you can do this. One would be to also have a relation on each post for likedBy so when a user likes a post, you add that user to the post's likedBy relation as well as adding the post the user's likes relation.
Another solution is to create a new Parse class for Like. Whenever a User likes a post, you create a new Like with a pointer to the Post and the User who liked it. Then if you want to find the posts that a user likes, you can easily query that, or if you want to know which users like a post, that query is just as simple.
I personally use the second approach, but either will work

How to join two belongsToMany objects

I am trying to represent friendships in my Laravel project database.
I have created a table profile which contains all user-data.
A second table profile_profile with the columns profile_id and friend_id.
With that I am able to get persons wo wants to be friend with me:
$this->belongsToMany('App\Profile', 'profile_profile', 'friend_id', 'friend_id');
an friends I am want to be befriendet:
$this->belongsToMany('App\Profile', 'profile_profile', 'profile_id', 'friend_id');
But in the end you are only friends if both want that so. So I tried to combined them but join or something similar didn't work.
I did a research on this platform and google over 2 hours. I am afraid that my skills are to limited, but I really like to ask for help.
Thank you in advance.
Quick solution: add another column in the profile_profile table, say, "accepted" as boolean and default to FALSE.
When a user accepts a friend's request, toggle the "accepted" field to TRUE.
Then you could search like $profile->profiles()->wherePivot('accepted', true)->get()

Laravel keep information about users on multiple sessions

I'm implementing my database. xD
Should I make changes, but I would like any further information about it, by those who are more experienced than me.
1) Should I make sure to keep a tracking for security reasons.
I would like to create a table "access", which contains the following fields.
id, id_user, browser, os, dates, ip.
What should I change, to ensure that each time the user login, is added a new record in this table.
If you have more tips on how to improve this point, I'd be grateful.
2) I would like to do so you can make the user choose whether the session of his choice or whether permanent or not.
I could only find a way to do it, that the session lasting for a certain period of time.
But I would like to implement a graft.
3) Should I implement multiple sessions, I'll explain.
The possibility that every user experience their sessions, such as facebook ago.
You can see how many active sessions exist and on what date.
I thought at a table like this:
id, id_user, queues, browser, os, dates, ip.
What do you think, you can do what?
If yes, what should I change in the structure of laravel to do this?
Thank you in advance who will help me.
I apologize for my English and the long text.
1) You should use also timestamp that logging table. You can use the built in updated_at and created_at timestamps. In your login function simply create a new instance of the model, populate the attributes and save() it.
2) There is a built in remember me behavior that you can use. More details can be found in the Laravel docs http://laravel.com/docs/4.2/security
3) Can you explain more of why you would want to implement multiple sessions? Why would this be useful for your application?
I hope my answer helps.

Joomla 'sobipro' - extracting data

I have taken over a Joomla project that needs rebuilding.
I need to get out the user data and some other data linked to users, I have found most of it in the jos_user table and also a table named jos_comprofiler.
There is data inside of jos_sobipro_field_data that I also need, but I do not know how this table related to anything else can someone please explain? I am able to write SQL and the JOIN statements to get it out once I understand how it all fits together.
Finally the table jos_comprofiler references an avatar which is an image name like '100_4f97c0b3c2c31.jpg' where can I find these images?
Thanks, Jake
I can tell you where those tables are coming from:
- jos_users is the user table used by Joomla core, together with jos_user_profiles for additional profile information.
- jos_comprofiler is a table created by the Community Builder extension from http://www.joomlapolis.com/.
- jos_sobipro_field_data is a table created by SobiPro from http://sobipro.sigsiu.net/
Maybe that helps you find the next steps. Maybe someone else knows more details.

Resources