/**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if ($this->input('delete') == 'on') {
         return [];
     }
     $SpeedDial = SpeedDial::find($this->route('id'));
     $old = UsedExtension::where('customer', Auth::user()->customer)->where('extension', $SpeedDial->sd_exten)->first();
     return ['sd_extension' => 'required|numeric|min:2|unique:used_extensions,extension,' . $old->id . ',id,customer,' . Auth::user()->customer, 'destination_type' => 'required', 'forward' => 'required_if:destination_type,forward|numeric', 'extension' => 'required_if:destination_type,extension', 'ivr' => 'required_if:destination_type,ivr', 'ringgroup' => 'required_if:destination_type,ringgroup', 'schedule' => 'required_if:destination_type,schedule', 'confbridge' => 'required_if:destination_type,confbridge', 'voicemail' => 'required_if:destination_type,voicemail', 'queue' => 'required_if:destination_type,queue'];
 }
Ejemplo n.º 2
0
 public function delete()
 {
     parent::delete();
     $Extensions = Extension::where('app', 'ConfBridge')->where('appdata', Auth::user()->customer . '_' . $this->conf_name)->where('customer', Auth::user()->customer)->get();
     foreach ($Extensions as $Extension) {
         if ($Extension->context == Auth::user()->Customer->internal_context) {
             UsedExtension::where('customer', Auth::user()->customer)->where('extension', $Extension->exten)->delete();
         }
         Extension::where('context', $Extension->context)->where('exten', $Extension->exten)->where('customer', Auth::user()->customer)->delete();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\ConferenceBridgeRequest $request)
 {
     $Bridge = ConferenceBridge::create(['customer' => Auth::user()->customer, 'conf_name' => $request->input('conf_name'), 'conf_auth' => $request->input('conf_auth')]);
     if ($request->input('conf_extension')) {
         AsteriskController::genRoute(Auth::user()->Customer->internal_context, $request->input('conf_extension'), 'confbridge', $Bridge->id);
         /*Extension::firstOrCreate([
               'context' => Auth::user()->Customer->internal_context,
               'exten' => $request->conf_extension,
               'priority' => '1',
               'app' => 'Answer',
               'appdata' => '',
               'customer' => Auth::user()->customer
           ]);
           $priority=2;
           if($request->input('conf_auth')){
               Extension::firstOrCreate([
                   'context' => Auth::user()->Customer->internal_context,
                   'exten' => $request->conf_extension,
                   'priority' => $priority,
                   'app' => 'Authenticate',
                   'appdata' => $request->input('conf_auth'),
               'customer' => Auth::user()->customer
               ]);
               $priority++;
           }
           Extension::firstOrCreate([
               'context' => Auth::user()->Customer->internal_context,
               'exten' => $request->conf_extension,
               'priority' => $priority,
               'app' => 'ConfBridge',
               'appdata' => Auth::user()->customer.'_'.$request->input('conf_name'),
               'customer' => Auth::user()->customer
           ]);*/
         UsedExtension::create(['customer' => Auth::user()->customer, 'extension' => $request->input('conf_extension')]);
     }
     return redirect('/conf');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\UpdateSpeedDialRequest $request, $id)
 {
     $SpeedDial = SpeedDial::find($id);
     if ($request->input('delete') == 'on') {
         if ($SpeedDial->isInUse()) {
             \Session::flash('error_message', "Cannot delete a speed dial that is in use");
             return redirect()->back();
         }
         UsedExtension::where('customer', Auth::user()->customer)->where('extension', $SpeedDial->sd_exten)->delete();
         $SpeedDial->delete();
         \Session::flash('success_message', "Speed Dial deleted");
         return redirect('/queue');
     }
     $SpeedDial->sd_exten = $request->input('sd_extension');
     $SpeedDial->sd_dest_type = $request->input('destination_type');
     $SpeedDial->save();
     \Session::flash('success_message', "Speed Dial updated");
     return redirect('/speeddials');
 }