コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\UserRequest $request)
 {
     $newUser = User::create(['username' => $request->input('username'), 'password' => Hash::make($request->input('password')), 'fullname' => $request->input('fullname'), 'customer' => Auth::user()->customer, 'email' => $request->input('email'), 'permlevel' => $request->input('permlevel'), 'vmenabled' => $request->input('enable_voicemail')]);
     UserSettings::create(['user' => $newUser->id]);
     $newPeer = Peer::create(['name' => Auth::user()->customer . '_' . $newUser->id, 'callerid' => Auth::user()->Customer->default_callerid, 'defaultuser' => Auth::user()->customer . '_' . $newUser->id, 'secret' => Peer::genSecret(), 'mailbox' => $newUser->id . '@' . Auth::user()->customer, 'portaluid' => $newUser->id]);
     $newUser->peer = $newPeer->id;
     $newUser->save();
     $blfText = file_get_contents(env('EXTENSIONS_CONF_FILE_PATH'));
     $blfText = str_replace("[BLF]\n", "[BLF]\nexten => " . $newPeer->getHint() . ",hint,SIP/" . $newPeer->name . "\n", $blfText);
     file_put_contents(env('EXTENSIONS_CONF_FILE_PATH'), $blfText);
     $newMailbox = VoicemailBox::create(['customer_id' => $newUser->id, 'context' => $newUser->customer, 'mailbox' => $newUser->id, 'password' => $request->input('vmpassword'), 'fullname' => $newUser->fullname, 'email' => $newUser->email, 'sip_buddy_id' => $newPeer->id, 'attach' => $request->input('enable_email'), 'delete' => $request->input('enable_email')]);
     $newPeer->vmrow = $newMailbox->uniqueid;
     $newPeer->save();
     return redirect('/user');
 }
コード例 #2
0
 public function getRelatedUserAttribute()
 {
     return Peer::find($this->sip_buddy_id)->User->fullname ?? $this->mailbox_name ?? 'Unkown';
 }