Advertisement
Guest User

Untitled

a guest
Nov 24th, 2020 (edited)
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.10 KB | None | 0 0
  1. title = "user"
  2. url = "/user"
  3. layout = "default"
  4. is_hidden = 0
  5. robot_index = "index"
  6. robot_follow = "follow"
  7.  
  8. [session]
  9. security = "all"
  10.  
  11. [account]
  12. paramCode = "code"
  13. forceSecure = 0
  14. requirePassword = 0
  15. ==
  16. <?php
  17. use RainLab\User\Models\User as UserModel;
  18.  
  19.    function onSave()
  20.    {
  21.  
  22.        $data = post();
  23.  
  24.        $rules = [
  25.            'name' => 'required',
  26.             'email' => 'required|email',
  27.             'password' => 'confirmed|min:8',
  28.         ];
  29.  
  30.         $validation = Validator::make($data, $rules);
  31.  
  32.         if ($validation->fails()) {
  33.             throw new ValidationException($validation);
  34.         }
  35.  
  36.         $id = input('id');
  37.  
  38.         $user = UserModel::where('id', $id)->first();
  39.  
  40.         $user->fill($data);
  41.  
  42.  
  43.         $notescount = input('notescount');
  44.        
  45. //      dd($notescount);
  46.  
  47.        
  48.  
  49.         $notes = [];
  50.        
  51.         for ($i = 1; $i <= $notescount; $i++) {
  52.            
  53.            if(input('note' . $i)){
  54.             $notes[] = ['notes' => input('note' . $i) ];
  55.            }
  56.         }
  57.        
  58.         $user->setField('myfields', $notes);
  59.  
  60.  
  61.         $user->save();
  62.  
  63.         Flash::success('Successfully saved!');
  64.  
  65.         if (array_key_exists('password', $data) && strlen($data['password'])) {
  66.  
  67.            Auth::login($user->reload(), true);
  68.  
  69.         }
  70.  
  71.     }
  72. ?>
  73. ==
  74. <section id="demo" class="section demos bg-gray">
  75.         <div class="container">
  76.             <div class="row">
  77.                 <div class="col-sm-12 text-center section-title">
  78.  
  79.                     <br>
  80.                     {% if not user %}
  81.  
  82.                     {% component 'account' %}
  83.  
  84.                     {% endif %}
  85.  
  86.                     {% if user %}
  87.  
  88.                     <div id="customfields">
  89.                         {% partial 'user' %}
  90.                     </div>
  91.  
  92.                     <p>Hello {{ user.name }}</p>
  93.  
  94.                     <a data-request="onLogout" data-request-data="redirect: '/user'">Sign out</a>
  95.  
  96.                     {% else %}
  97.                     <p>Nobody is logged in</p>
  98.                     {% endif %}
  99.  
  100.                 </div>
  101.             </div>
  102.         </div>
  103.     </section>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement