programming:phplaravel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
programming:phplaravel [2022/09/11 03:53] adminprogramming:phplaravel [2022/09/19 16:57] (current) – [laravel.Development] admin
Line 9: Line 9:
 $methods = (new ReflectionClass('\App\Models\User'))->getMethods(); $methods = (new ReflectionClass('\App\Models\User'))->getMethods();
  
-$u=User::->find(5);+$u=User::find(5);
  
 show $u # show source show $u # show source
Line 31: Line 31:
 # execute code in tinker from file # execute code in tinker from file
 include('/var/www/laravel/storage/app/tinker/update_users.php') include('/var/www/laravel/storage/app/tinker/update_users.php')
 +
 +####### - обновление роли 
 +#найти пользователя 
 +User::with(['roles:id,name'])->where('id','305')->get(['id','name']);
 +User::with('digitalCertificates','roles')->where('name','LIKE', '%Ворончихин%')->first()
 +User::with('Roles')->where('name','LIKE', '%Шестакова%')->get(['id','name'])
 +User::with('Roles:id,name')->where('name','LIKE', '%Долматова%')->first(['id','name'])
 + 
 + 
 +#Обновление
 +User::where('name','LIKE', '%тампель%')->first()->roles()->detach(Role::where(['code' => 'user'])->first());
 +User::where('name','LIKE', '%Ворончихин%')->first()->roles()->syncWithoutDetaching(Role::where(['code' => 'user'])->first());
 +User::find(450)->roles()->syncWithoutDetaching(Role::where(['code' => 'user'])->first());
 + 
 + 
 +function addUser($uid) {
 +  return User::find($uid)->roles()->syncWithoutDetaching(Role::where(['code' => 'user'])->first());
 +}
 </code> </code>
 ++++ Get All Models| ++++ Get All Models|
Line 156: Line 174:
 ==== laravel.Development ==== ==== laravel.Development ====
   * Laravel's Dependency Injection Container in Depth https://gist.github.com/davejamesmiller/bd857d9b0ac895df7604dd2e63b23afe   * Laravel's Dependency Injection Container in Depth https://gist.github.com/davejamesmiller/bd857d9b0ac895df7604dd2e63b23afe
 +  * laravel queues https://www.honeybadger.io/blog/laravel-queues-deep-dive/#introduction-to-jobs-queues-and-workers
   * laracast - namespace https://laracasts.com/lessons/namespacing-primer    * laracast - namespace https://laracasts.com/lessons/namespacing-primer 
   * laravel auth guard https://darkghosthunter.medium.com/laravel-making-your-own-passwordless-auth-guard-b7740c89adf8   * laravel auth guard https://darkghosthunter.medium.com/laravel-making-your-own-passwordless-auth-guard-b7740c89adf8
  • programming/phplaravel.1662868387.txt.gz
  • Last modified: 2022/09/11 03:53
  • by admin