Início / Optitravel / Models
delete($id)
This method deletes a specific record from the database, using the value of the primary key to identify which row to remove.
It's a direct operation that permanently removes the resource from the corresponding table.
Parameters
- $id – The value of the primary key that identifies the record to delete.
Returns:
- A boolean result (true or false) indicating whether the deletion was successful.
Example:
use \App\Models\User;
$user = new User();
$deleted = $user->delete(1);
if ($deleted) {
echo "User deleted successfully.";
} else {
echo "Deletion failed.";
}
Notes
- This method executes a SQL DELETE command directly. Use it with caution.
↑ (Última atualização: 06/05/2025)