Get the users who are sent themselves of the messages with the last messages and to sort out by created_at - laravel-5.8

I have a serious problem with the threads that makes some days now. I use Laravel 5.8, during all these times I have make some research everywhere and I read full of the articles but no of the gotten reply could not solve my problem, If he/it pleases you I have bésoin of your helps. I want récupperer all users who sent messages with the connected user and all what were contact by him with the last message by created_at of the messages.
thanks for your helps !!!
This some informations
migration table
table from database
And view

Related

Laravel - Storing Emails in Database

I'm trying to find an option where I can store the body of an email message, the addresses it was sent to and the subject and store it in the database where it can be related back to various models. Is there such a way I can handle this?
I'm not sure where to start. I know there is a callback on the message sent, but if this can be related back to man different models with many different IDs, how can I save the relationship between that particular model a message was sent about in the database?
you might need to check polymorphic relations in laravel https://laravel.com/docs/8.x/eloquent-relationships#one-to-many-polymorphic-relations
basically what it does that it would allow you to have relations between you email model and multiple models

Laravel private messaging system . Fetch all related users issue

I am referring to this thread
Laravel 4 Relationship: messaging system
I created the tables and also made the relations inside both model "Message" and "User".
Now i can fetch the list of messages sent by me through this command
user::find($myid)->sent_messages()->get();
MY QUESTIONS IS
How can we get list of users that has been messaging to me (logged in user) ?
I mean in the messages table "from" can be logged in user (1) or "to" can be logged in user (1) . I want to get list of other users that are chatting with the (logged in user) .
Hope you understand my question and help. I am new to laravel and trying to learn things and best practises. If you have suggestion to use any messaging system already there in github. I found one name "Laravel-messenger" but not suited to me.
Your suggestions and answer are highly appreciated. THANKS
May be instead of using table user_messages (just drop it) you just modify table Messages to below form:
Messages: id | from_user_id | to_user_id | content
Then you can make query:
$received = Messges::where('to_user_id','=',my_user_id);
$send = Messges::where('from_user_id','=',my_user_id);
$result = $received->union($send)->get();
(BONUS: you can also add column replay_from_message_id (null for first message) to save backward sequence of messages (thread). And then you can also add column first_message_id to simplify getting thread query)

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.

Magento sells products but fails to store the order

I have a silly problem - a Magento 1.7.2.0 that works just fine, except for now and then it does not store the order in the database.
Emails go out, payment gets processed (owner gets confirmation from PayPal, for example) but no order is stored in the database. I did not rely on grid only, I checked the database - and nothing is there.
Also, last time this happened I checked increment values in eav_entity_store and thy were not updated - it says 130000030 and in the email order is numbered 130000031 - so somewhere in the process it crashes.
First idea was to look in the error log but I was not able to see anything there that I could relate to this.
Now I need a fresh idea. Any thoughts?
Thanks

how to auto-delete records that have expired in data/time

Hey I hope you can help me,
I am trying to find a way to let rails auto-delete records who have reached their expiring date.
I got an 'appointment' model where the user can set date and time. The records are viewed ascending in a table. I want to destroy it after its done.
Many thanks!
It's not a common practice in databases to delete things when you do not want to see them anymore. Instead, I would suggest you to filter your table records based on the expiry date, and on the current date. This way, you are also able to display expired appointments, if necessary.
Hope this helps!

Resources