// HI, I am currently working on a laravel php project, the project previously connected with slack and send notifications to slack. Now I need to send notifications to Teams, so I need to follow the previous slack notifications. for the database, I have a user table contained slack_incoming_hook, and I added a column called ‘teams_incoming_hook’ just like “slack_incoming_hook”. Next, I modified user.php file, it has a creation function and a store function to create and store the input value. I added teams_incoming_hook following slack_incoming_hook.
// user.php:
class User extends Authenticatable
{
protected $fillable = [
'slack_incoming_hook',
'teams_incoming_hook'
];
static public function create(Request $request){
$user = new User;
$user->slack_incoming_hook = $request->slack_incoming_hook;
$user->teams_incoming_hook = $request->teams_incoming_hook;
$user->save();
}
static public function create(Request $request){
$user->slack_incoming_hook = $request->slack_incoming_hook;
$user->teams_incoming_hook = $request->teams_incoming_hook;
}
static public function store(Request $request){
DB::transaction(function () use ($request) {
$user = User::find($request->id);
if($user){
if($request->slack_incoming_hook != ""){
$user->slack_incoming_hook = $request->slack_incoming_hook;
}
if($request->teams_incoming_hook != ""){
$user->teams_incoming_hook = $request->teams_incoming_hook;
}
$user->update();
}
}
}
// here is the edit-user.blade.php code:
<div class="col-span-3 sm:col-span-2">
<label for="slack_incoming_hook" class="block text-sm font-medium text-gray-700">
Slack Webhook Url
</label>
<div class="mt-1 flex rounded-md shadow-sm">
<input type="text" name="slack_incoming_hook" id="slack_incoming_hook" class="focus:ring-green-200 focus:border-green-200 flex-1 block w-full rounded-none rounded-l-md rounded-r-md sm:text-sm border-gray-300" value="{{ $user['slack_incoming_hook']}}">
</div>
<x-small-text.danger class="slack_incoming_hook_error"></x-small-text.danger>
</div>
<div class="col-span-3 sm:col-span-2">
<label for="teams_incoming_hook" class="block text-sm font-medium text-gray-700">
Teams Webhook Url
</label>
<div class="mt-1 flex rounded-md shadow-sm">
<input type="text" name="teams_incoming_hook" id="teams_incoming_hook" class="focus:ring-green-200 focus:border-green-200 flex-1 block w-full rounded-none rounded-l-md rounded-r-md sm:text-sm border-gray-300" value="{{ $user['teams_incoming_hook']}}">
</div>
<x-small-text.danger class="teams_incoming_hook_error"></x-small-text.danger>
</div>
and I tried to modify the User table directly and the value can show on the UI page.
Please help me to figure it out. Many THX!