PHP code example of finller / laravel-conversations
1. Go to this page and download the library: Download finller/laravel-conversations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
finller / laravel-conversations example snippets
return [
/**
* The Model used with the user_id and owner_id
*/
'model_user' => User::class,
'model_message' => Message::class,
'model_conversation' => Conversation::class,
/**
* When a User is deleted, his messages will be deleted
*/
'cascade_user_delete_to_messages' => false,
/**
* When a User is deleted, his messages will be deleted
*/
'cascade_conversation_delete_to_messages' => false,
/**
* When the parent of a conversation is deleted, the conversation is deleted
*/
'cascade_conversationable_delete_to_conversation' => false,
];
$conversation = new Conversation();
$conversation->conversationable()->associate($mission); // optional
$conversation->save();
$conversation->users()->sync($usersIds);
$message = new Message([
'content' => "My message",
]);
$message->user()->associate($this->user);
$this->conversation->messages()->save($message);