programming:phplaravel

This is an old revision of the document!


php Artisan tinker example user:

# $laravel artisan tinker 
# list all method of reflection 
$methods = (new ReflectionClass('\App\Models\User'))->getMethods();
 
$u=User::->find(5);
 
show $u # show source
dump $u # show data
show App\Models\User # show source code

 
$u=User::with(['digitalCertificates','roles'])->find(5);
 
# find user with releations and add role 
$u=User::with(['digitalCertificates','roles'])->find(8);
$u->roles()->save(App\Models\Role::find(2));
$u->refresh();
 
 
App\Models\Role::create(['id' => 2,   'code' => "archivist",'name' => "Архивист"]);

Get All Models

  • programming/phplaravel.1662784499.txt.gz
  • Last modified: 2022/09/10 04:34
  • by admin