// Define a model class for "users" table use Illuminate\Database\Eloquent\Model; class User extends Model { protected $table = 'users'; protected $fillable = ['name', 'email', 'password']; }
// Create a new user $user = new User; $user->name = 'John Doe'; $user->email = 'johndoe@example.com'; $user->password = bcrypt('secret'); $user->save();
// Find a user by ID $user = User::find(1); // Update a user's name $user->name = 'Jane Doe'; $user->save();This example finds a user by their ID and updates their name using the model. The `save()` method is used to save the changes to the database. Overall, php illuminate.database.eloquent Model is a powerful package library for managing database records in PHP applications. It provides a simple, intuitive syntax and a range of useful features for working with databases. It is part of the Laravel framework.