Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1.     public function update(SMSTemplate $sms, Request $request)
  2.     {
  3.         //--
  4.         $this->_security($sms, 'sms');
  5.         //--
  6.        
  7.         $this->validate($request, $this->_rules($sms));
  8.        
  9.         $sms->client_id     = \Auth::user()->client_id;
  10.         $sms->name          = $request->input('name');
  11.         $sms->sender        = $request->input('sender');
  12.         $sms->text          = $request->input('text');
  13.         $sms->save();
  14.        
  15.         return redirect()->route('sms.index')->with('success', 'SMS template successfully updated!');
  16.     }
  17.  
  18.     public function _rules($sms = false)
  19.     {
  20.         $rules['name']      = 'required|min:1|max:200|unique:sms_templates,name,NULL,id,client_id,'.\Auth::user()->client_id;
  21.         $rules['sender']    = 'required|min:1|max:50';
  22.         $rules['text']      = 'min:1|max:3000';
  23.        
  24.         if($sms) {
  25.             $rules['name']  = 'required|min:1|max:200|unique:sms_templates,name,'.$sms->id.',id,client_id,'.\Auth::user()->client_id;
  26.         }
  27.        
  28.         return $rules;
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement