Skip to content

Commit

Permalink
added type column to conversation (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
myckhel authored Jun 23, 2021
1 parent 2341ace commit b8d2d00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function up()
$table->id();
$table->foreignId('user_id')->constrained($user_table)->onDelete('cascade');
$table->string('name')->nullable();
$table->enum('type', ['private', 'group', 'issue'])->default('private')->index();
$table->timestamps();
});
}
Expand Down
10 changes: 8 additions & 2 deletions src/Http/Controllers/ConversationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,20 @@ public function create()
*/
public function store(Request $request)
{
$request->validate([
@[
'name' => $name,
'type' => $type,
] = $request->validate([
'name' => 'string',
'type' => 'in:private,group,issue',
]);

$user = $request->user();

return $user->conversations()->create([
'user_id' => $user->id,
'name' => $request->name,
'name' => $name,
'type' => $type,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class Conversation extends Model
{
use HasFactory, HasChatEvent, Config;
protected $fillable = ['user_id', 'name'];
protected $fillable = ['user_id', 'name', 'type'];
protected $casts = ['user_id' => 'int'];
protected $hidden = ['pivot'];

Expand Down

0 comments on commit b8d2d00

Please sign in to comment.